Example #1
0
    /// <summary>
    /// Updates the cube grid.
    /// </summary>
    void UpdateCubeGrid()
    {
        // Toggle the grid cube display on 'G'
        if (Input.GetKeyDown(KeyCode.G))
        {
            if (CubeGridOn == false)
            {
                CubeGridOn = true;
                Debug.LogWarning("CubeGrid ON");
                if (CubeGrid != null)
                {
                    CubeGrid.SetActive(true);
                }
                else
                {
                    CreateCubeGrid();
                }

                // Add the CameraCubeGrid to the camera list for update
                OVRCamera.AddToLocalCameraSetList(ref CameraCubeGrid);
            }
            else
            {
                CubeGridOn = false;
                Debug.LogWarning("CubeGrid OFF");

                if (CubeGrid != null)
                {
                    CubeGrid.SetActive(false);
                }

                // Remove the CameraCubeGrid from the camera list
                OVRCamera.RemoveFromLocalCameraSetList(ref CameraCubeGrid);
            }
        }

        if (CubeGrid != null)
        {
            // Set cube colors to let user know if camera is tracking
            CubeSwitchColor = !OVRDevice.IsCameraTracking();

            if (CubeSwitchColor != CubeSwitchColorOld)
            {
                CubeGridSwitchColor(CubeSwitchColor);
            }
            CubeSwitchColorOld = CubeSwitchColor;
        }
    }