using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; using UnityEngine.UI; public class VRCanvasManager : MonoBehaviour { public static VRCanvasManager Instance { get { if (VRCanvasManager.m_Instance == null) { VRCanvasManager.m_Instance = UnityEngine.Object.FindObjectOfType(); } return VRCanvasManager.m_Instance; } } public UICanvasFade CanvasParent { get { return this.m_CanvasParent; } } public bool IsYotogiSelecting { get { return this.m_IsYotogiSelecting; } set { this.m_IsYotogiSelecting = value; } } private void Awake() { VRCanvasManager.m_Instance = this; this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.MainMenu, this.m_CanvasMainMenu); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.Manual, this.m_CanvasManual); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.NeiLetter, this.m_CanvasNeiLetter); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.Dialog, this.m_CanvasDialog); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.VRConfig, this.m_CanvasVRConfig); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.PhotoMode, this.m_CanvasPhotoMode); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.MoviePlayer, this.m_CanvasMoviePlayer); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.MusicPlayer, this.m_CanvasMusicPlayer); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.Selector, this.m_CanvasSelector); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.Culture, this.m_CanvasCulture); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.Trophy, this.m_CanvasTrophy); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.VIP, this.m_CanvasVIP); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.ChangeBG, this.m_CanvasChangeBG); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.RentalMaid, this.m_CanvasRentalMaid); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.Tutorial, this.m_CanvasTutorial); this.m_CanvasArray.Add(VRCanvasManager.VRCanvasType.DecideUseTouch, this.m_CanvasDecideUseTouch); } private void Start() { Camera componentInChildren = EventSystem.current.gameObject.GetComponentInChildren(); foreach (Canvas canvas in this.m_CanvasArray.Values) { canvas.worldCamera = componentInChildren; } } private void Update() { CanvasGroup component = this.m_CanvasParent.GetComponent(); if (!GameMain.Instance.OvrMgr.OvrCamera.IsUIShow) { component.interactable = false; component.blocksRaycasts = false; component.alpha = 0f; return; } bool isFallThrough = GameMain.Instance.OvrMgr.OvrCamera.IsFallThrough; if (isFallThrough) { component.interactable = true; component.blocksRaycasts = true; } else { component.interactable = false; component.blocksRaycasts = false; } bool isRotDown = GameMain.Instance.OvrMgr.OvrCamera.OvrTablet.IsRotDown; bool isSideBack = GameMain.Instance.OvrMgr.OvrCamera.OvrTablet.IsSideBack; Vector3 zero = Vector3.zero; zero.z = ((!isRotDown) ? 0f : 180f); zero.y = ((!isSideBack) ? 0f : 180f); zero.x = 0f; this.m_CanvasParent.transform.localEulerAngles = zero; } private void LateUpdate() { bool isUIShow = GameMain.Instance.OvrMgr.OvrCamera.IsUIShow; bool isFreeMode = SceneVRCommunication.Instance.IsFreeMode; bool uiNoMoveMode = SceneVRCommunication.Instance.UiNoMoveMode; bool uiNoHomeMode = SceneVRCommunication.Instance.UiNoHomeMode; bool flag = GameMain.Instance.MainCamera.IsFadeProc(); bool flag2 = GameMain.Instance.MainCamera.IsFadeOut(); bool isEnableSkip = SceneVRCommunication.Instance.IsEnableSkip; bool uiNoTimeMode = SceneVRCommunication.Instance.UiNoTimeMode; bool beforeShowUI = this.m_BeforeShowUI; bool beforeFreeMode = this.m_BeforeFreeMode; bool beforeNoMoveMode = this.m_BeforeNoMoveMode; this.m_BeforeShowUI = isUIShow; this.m_BeforeFreeMode = isFreeMode; this.m_BeforeNoMoveMode = uiNoMoveMode; CanvasGroup component = this.m_CanvasParent.GetComponent(); if (isUIShow) { if (uiNoHomeMode) { component.blocksRaycasts = false; component.alpha = 0f; } else if (!this.m_IsYotogiSelecting) { component.alpha = 1f; } else { component.blocksRaycasts = false; component.alpha = 0f; } } this.SetMainMenuButtonEnable(VRMainMenu.ButtonType.Edit, isFreeMode); this.SetMainMenuButtonEnable(VRMainMenu.ButtonType.Yotogi, isFreeMode); this.SetMainMenuButtonEnable(VRMainMenu.ButtonType.Time, isFreeMode && !uiNoTimeMode); this.SetMainMenuButtonEnable(VRMainMenu.ButtonType.ChangeBG, !uiNoMoveMode && isFreeMode); this.SetMainMenuButtonEnable(VRMainMenu.ButtonType.Skip, !isFreeMode && isEnableSkip); this.SetMainMenuButtonActive(VRMainMenu.ButtonType.Skip, !isFreeMode && isEnableSkip); if (!isFreeMode && beforeFreeMode) { this.ClearCanvasStack(); this.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu); } if (uiNoMoveMode && !beforeNoMoveMode) { this.ClearCanvasStack(); this.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu); } bool flag3 = false; flag3 |= this.m_CanvasVRConfig.gameObject.activeInHierarchy; flag3 |= this.m_CanvasSelector.gameObject.activeInHierarchy; flag3 |= this.m_CanvasDialog.gameObject.activeInHierarchy; flag3 |= this.m_CanvasTutorial.gameObject.activeInHierarchy; flag3 |= this.m_CanvasDecideUseTouch.gameObject.activeInHierarchy; if (flag3 && isUIShow) { component.blocksRaycasts = true; component.alpha = 1f; } GameMain.VRDeviceType vrdeviceTypeID = GameMain.Instance.VRDeviceTypeID; if (vrdeviceTypeID != GameMain.VRDeviceType.NON && vrdeviceTypeID != GameMain.VRDeviceType.RIFT && vrdeviceTypeID != GameMain.VRDeviceType.FOVE) { bool isHandCameraMode = GameMain.Instance.OvrMgr.OvrCamera.IsHandCameraMode; if (!this.m_IsYotogiSelecting) { if (isHandCameraMode && !this.m_BeforeHandCameraMode && isFreeMode && this.m_CanvasArray[VRCanvasManager.VRCanvasType.MainMenu].gameObject.activeInHierarchy) { this.OpenVRCanvas(VRCanvasManager.VRCanvasType.PhotoMode); } else if (this.m_CanvasArray[VRCanvasManager.VRCanvasType.PhotoMode].gameObject.activeInHierarchy && ((!isHandCameraMode && this.m_BeforeHandCameraMode) || (!isFreeMode && this.m_BeforeFreeMode))) { this.m_CanvasPhotoMode.GetComponent().FadeOut(); if (this.m_CanvasArray[VRCanvasManager.VRCanvasType.MainMenu].gameObject.activeSelf) { this.ClearCanvasStack(); } else if (!this.IsExistsBeforeVRCanvas()) { this.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu); } else { this.OpenBeforeVRCanvas(); } } } this.m_BeforeHandCameraMode = isHandCameraMode; } if (flag || flag2) { component.blocksRaycasts = false; } } public void OpenVRCanvas() { this.m_CanvasParent.FadeIn(); CanvasGroup component = this.m_CanvasParent.GetComponent(); component.alpha = 1f; component.interactable = true; component.blocksRaycasts = true; } public virtual void OpenVRCanvas(VRCanvasManager.VRCanvasType type) { if (!base.enabled) { return; } bool isUIShow = GameMain.Instance.OvrMgr.OvrCamera.IsUIShow; if (isUIShow) { this.m_CanvasParent.FadeIn(); } GameObject mainCanvas = null; if (this.m_CanvasArray.ContainsKey(type)) { mainCanvas = this.m_CanvasArray[type].gameObject; } this.ChangeCanvas(mainCanvas); } public void CloseVRCanvas() { foreach (KeyValuePair keyValuePair in this.m_CanvasArray) { Canvas value = keyValuePair.Value; UICanvasFade component = value.GetComponent(); if (component) { value.gameObject.SetActive(false); } } CanvasGroup component2 = this.m_CanvasParent.GetComponent(); component2.alpha = 0f; component2.interactable = false; } public virtual void ChangeCanvas(GameObject MainCanvas) { if (!this.m_BeforeShowUI) { for (int i = 0; i < this.m_CanvasParent.transform.childCount; i++) { GameObject gameObject = this.m_CanvasParent.transform.GetChild(i).gameObject; UICanvasFade component = gameObject.GetComponent(); if (MainCanvas != gameObject) { if (component != null && gameObject.activeInHierarchy) { this.m_CanvasStack.Add(component); } if (component) { component.FadeOut(0f, false, null); } } else { component.FadeIn(0f, false, null); } } } else { List list = new List(); for (int j = 0; j < this.m_CanvasParent.transform.childCount; j++) { GameObject gameObject2 = this.m_CanvasParent.transform.GetChild(j).gameObject; UICanvasFade component2 = gameObject2.GetComponent(); if (MainCanvas != gameObject2 && component2 != null && gameObject2.activeInHierarchy) { list.Add(component2); this.m_CanvasStack.Add(component2); } } for (int k = 1; k < list.Count; k++) { list[k].FadeOut(); } if (list.Count > 0) { float fadeTime = list[0].fadeTime; bool isTimeScaling = list[0].isTimeScaling; list[0].FadeOut(fadeTime, isTimeScaling, delegate() { if (MainCanvas) { MainCanvas.GetComponent().FadeIn(); } }); } else if (MainCanvas) { MainCanvas.GetComponent().FadeIn(); } } } public void OpenBeforeVRCanvas() { if (this.m_CanvasStack.Count <= 0) { return; } UICanvasFade uicanvasFade = this.m_CanvasStack[this.m_CanvasStack.Count - 1]; this.m_CanvasStack.RemoveAt(this.m_CanvasStack.Count - 1); this.ChangeCanvas(uicanvasFade.gameObject); } public bool IsExistsBeforeVRCanvas() { return this.m_CanvasStack.Count > 0; } public void ClearCanvasStack() { this.m_CanvasStack.Clear(); } public void UpdateCanvas() { foreach (Canvas canvas in this.m_CanvasArray.Values) { InterfaceVRCanvas[] componentsInChildren = canvas.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].OnUpdateCanvas(); } } bool flag = true; foreach (Canvas canvas2 in this.m_CanvasArray.Values) { if (canvas2.gameObject.activeSelf) { flag = false; break; } } if (flag) { bool isFreeMode = SceneVRCommunication.Instance.IsFreeMode; bool uiNoHomeMode = SceneVRCommunication.Instance.UiNoHomeMode; if (isFreeMode && !uiNoHomeMode && this.m_CanvasArray != null) { Canvas canvas3 = null; if (this.m_CanvasArray.TryGetValue(VRCanvasManager.VRCanvasType.MainMenu, out canvas3)) { UICanvasFade component = this.m_CanvasArray[VRCanvasManager.VRCanvasType.MainMenu].GetComponent(); component.FadeIn(); } } } } public void OpenVRConfig(UnityAction callback) { this.OpenVRCanvas(VRCanvasManager.VRCanvasType.VRConfig); Canvas canvas = this.m_CanvasArray[VRCanvasManager.VRCanvasType.VRConfig]; Transform transform = canvas.transform.Find("Button return"); Button button = transform.GetComponent