shenjianxing 40de877779 适配VR
2025-04-02 14:37:35 +08:00

48 lines
1.1 KiB
C#

using CG.Framework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using ZXK.LouDiXvMuNiu;
public class UIRoot : MonoSingleton<UIRoot>
{
public GameObject pcCanvas;
public GameObject vrRoot;
Transform vrCamera;
EventSystem eventsytem;
protected override void AwakeSelf()
{
base.AwakeSelf();
#if VR
vrRoot.gameObject.SetActive(true);
vrCamera = vrRoot.transform.Find("ZFrame");
eventsytem = vrRoot.transform.Find("ZEventSystem").gameObject.GetComponent<EventSystem>();
#else
pcCanvas.gameObject.SetActive(true);
eventsytem = pcCanvas.transform.Find("EventSystem").GetComponent<EventSystem>();
#endif
}
public EventSystem GetEventSystem()
{
return eventsytem;
}
public GraphicRaycaster GetRaycaster()
{
return UI_Manage.Instance.GetComponent<GraphicRaycaster>();
}
public void SetCamera(Vector3 pos, Vector3 rot)
{
vrCamera.position = pos;
vrCamera.localEulerAngles = rot;
}
}