shenjianxing 6b341ae2b4 适配VR
2025-04-01 16:16:45 +08:00

43 lines
877 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIRoot : MonoBehaviour
{
public GameObject pcCanvas;
public GameObject vrRoot;
public static UIRoot instance;
Transform vrCamera;
private void Awake()
{
instance = this;
DontDestroyOnLoad(this);
#if VR
DontDestroyOnLoad(vrRoot);
vrRoot.gameObject.SetActive(true);
vrCamera = vrRoot.transform.Find("ZFrame");
#else
pcCanvas.gameObject.SetActive(true);
#endif
}
public GameObject GetEventSystem()
{
#if VR
return vrRoot.transform.Find("ZEventSystem").gameObject;
#else
return pcCanvas.transform.Find("EventSystem").gameObject;
#endif
}
public void SetCamera(Vector3 pos, Vector3 rot)
{
vrCamera.position = pos;
vrCamera.localEulerAngles = rot;
}
}