48 lines
1.1 KiB
C#
Raw Normal View History

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