protected virtual void Init() { //panel = GameObject.Find("UIWinGame/Panel"); if (!panel) { Debug.LogError("panel not found in UiWinGame"); } canvas = GetComponent <Canvas>().gameObject; // Setup mouse pointer pointer = GetComponent <OVRMousePointer>(); LockCursor(); CentreMouse(); GameObject playerObject = GameHandler.instance.PlayerController.gameObject; // We use OVRCameraRig to set rotations to cameras, // and to be influenced by rotation OVRCameraRig[] CameraRigs = playerObject.GetComponentsInChildren <OVRCameraRig>(); if (CameraRigs.Length == 0) { Debug.LogWarning("OVRPlayerController: No OVRCameraRig attached."); } else if (CameraRigs.Length > 1) { Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraRig attached."); } else { cameraRig = CameraRigs[0]; if (CameraRigs[0].centerEyeAnchor) { GetComponent <Canvas>().worldCamera = CameraRigs[0].centerEyeAnchor.GetComponent <Camera>(); } } inputModule = FindObjectOfType <OVRInputModule>(); }
void Awake() { Debug.Log(string.Format("OVRInspector Awake", 0)); playerLayer = GetLayerOrReportError("Player"); if (instance != null) { Debug.LogError("Existing OVRInspector"); GameObject.Destroy(gameObject); return; } instance = this; UpdateUIMaterials(); //Find prefabs buttonPrefab = (Button)Resources.Load("Prefabs/Button", typeof(Button)); folderPrefab = (Button)Resources.Load("Prefabs/Folder", typeof(Button)); eventSystemPrefab = (EventSystem)Resources.Load("Prefabs/EventSystem", typeof(EventSystem)); // Setup canvas and canvas panel builders canvas = transform.Find("Canvas").gameObject; leftPanel = new OVRInspectorPanelBuilder(canvas.transform.Find("LeftPanel").gameObject); rightPanel = new OVRInspectorPanelBuilder(canvas.transform.Find("RightPanel").gameObject); centerPanel = new OVRInspectorPanelBuilder(canvas.transform.Find("CenterPanel").gameObject); docsPanel = rightPanel.panel.transform.Find("DocsPanel").gameObject; controlsPanel = centerPanel; docsPanelText = docsPanel.GetComponentInChildren <Text>(); docsScroller = docsPanel.GetComponentInChildren <OVRGazeScroller>(); // Setup links between panels for continous mouse movement leftPanel.rightPanel = centerPanel; rightPanel.leftPanel = centerPanel; centerPanel.leftPanel = leftPanel; centerPanel.rightPanel = rightPanel; discomfortWarning = GetComponent <OVRDiscomfortWarning>(); //discomfortWarning = null; // Setup mouse pointer pointer = canvas.GetComponent <OVRMousePointer>(); currentPointerPanel = leftPanel; LockCursor(); // Pre-level stuff OnAwakeOrLevelLoad(); // Add UI panels that are part of the prefab LoadPanels(centerPanel.panel.transform, false); // Search for UI panels and add them to the context list SetupAttachedContexts(); CentreMouse(); Hide(); }