Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        cleanupCameras();

        ovrGui = new OVRGUI();
        ovrGui.SetCameraController(ref cameraController);
        ovrGui.SetFontReplace(timeFont);

        cubes = new GameObject[numCubes];
        for (int i = 0; i < numCubes; i++)
        {
            Vector3    position = Random.onUnitSphere * Random.Range(maxDistance / 2, maxDistance);
            GameObject o        = GameObject.Instantiate(cube, position, Quaternion.identity) as GameObject;


            BlinkySorty bs = o.GetComponent <BlinkySorty>();

            bs.leftCamera = cameraLeft;

            bs.numBlinks = (int)Random.Range(1, 7);
            cubes[i]     = o;
        }

        dest = ovrParent.transform.position;

        userSort = new ArrayList();
    }
Esempio n. 2
0
    // GUI

    // * * * * * * * * * * * * * * * * *
    // OnGUI
    void OnGUI()
    {
        // Important to keep from skipping render events
        if (Event.current.type != EventType.Repaint)
        {
            return;
        }

        // Fade in screen
        if (AlphaFadeValue > 0.0f)
        {
            AlphaFadeValue -= Mathf.Clamp01(Time.deltaTime / FadeInTime);
            if (AlphaFadeValue < 0.0f)
            {
                AlphaFadeValue = 0.0f;
                // We can turn on the render object so we can render the on-screen menu
                if (GUIRenderObject != null)
                {
                    GUIRenderObject.SetActive(true);
                }
            }
            else
            {
                GUI.color = new Color(0, 0, 0, AlphaFadeValue);
                GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), FadeInTexture);
                return;
            }
        }

        // Cache current active render texture
        RenderTexture previousActive = RenderTexture.active;

        // if set, we will render to this texture
        if (GUIRenderTexture != null)
        {
            RenderTexture.active = GUIRenderTexture;
            GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 0.0f));
        }

        // Update OVRGUI functions (will be deprecated eventually when 2D rendering
        // is removed from GUI)
        GuiHelper.SetStereoSpreadX(StereoSpreadX);
        GuiHelper.SetFontReplace(FontReplace);

        // If true, we are displaying information about the Rift not being detected
        // So do not show anything else
        if (GUIShowRiftDetected() != true)
        {
            GUIShowLevels();
            GUIShowVRVariables();
        }

        // Restore active render texture
        RenderTexture.active = previousActive;
    }
Esempio n. 3
0
    // GUI

    // * * * * * * * * * * * * * * * * *
    // OnGUI
    void OnGUI()
    {
        // Important to keep from skipping render events
        if (Event.current.type != EventType.Repaint)
        {
            return;
        }

        // Fade in screen
        if (AlphaFadeValue > 0.0f)
        {
            AlphaFadeValue -= Mathf.Clamp01(Time.deltaTime / FadeInTime);
            if (AlphaFadeValue < 0.0f)
            {
                AlphaFadeValue = 0.0f;
            }
            else
            {
                GUI.color = new Color(0, 0, 0, AlphaFadeValue);
                GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), FadeInTexture);
                return;
            }
        }



        // We can turn on the render object so we can render the on-screen menu
        if (GUIRenderObject != null)
        {
            if (ScenesVisible || ShowVRVars || Crosshair.IsCrosshairVisible() ||
                RiftPresentTimeout > 0.0f || DeviceDetectionTimeout > 0.0f ||
                ((MagCal.Disabled() == false) && (MagCal.Ready() == false))
                )
            {
                GUIRenderObject.SetActive(true);
            }
            else
            {
                GUIRenderObject.SetActive(false);
            }
        }

        //***
        // Set the GUI matrix to deal with portrait mode
        Vector3 scale = Vector3.one;

        if (CameraController.PortraitMode == true)
        {
            float h = OVRDevice.HResolution;
            float v = OVRDevice.VResolution;
            scale.x = v / h;                  // calculate hor scale
            scale.y = h / v;                  // calculate vert scale
        }
        Matrix4x4 svMat = GUI.matrix;         // save current matrix

        // substitute matrix - only scale is altered from standard
        GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);

        // Cache current active render texture
        RenderTexture previousActive = RenderTexture.active;

        // if set, we will render to this texture
        if (GUIRenderTexture != null)
        {
            RenderTexture.active = GUIRenderTexture;
            GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 0.0f));
        }

        // Update OVRGUI functions (will be deprecated eventually when 2D renderingc
        // is removed from GUI)
        GuiHelper.SetFontReplace(FontReplace);

        // If true, we are displaying information about the Rift not being detected
        // So do not show anything else
        if (GUIShowRiftDetected() != true)
        {
            GUIShowLevels();
            GUIShowVRVariables();
        }

        //GuiHelper.StereoDrawTexture(0.45f, 0.45f, 0.1f, 0.1f, ref TestImage, Color.white);
        Crosshair.OnGUICrosshair();

        // Restore active render texture
        RenderTexture.active = previousActive;

        // ***
        // Restore previous GUI matrix
        GUI.matrix = svMat;
    }
    // GUI

    /// <summary>
    /// Raises the GU event.
    /// </summary>
    void OnGUI()
    {
        // Important to keep from skipping render events
        if (Event.current.type != EventType.Repaint)
        {
            return;
        }

        // Fade in screen
        if (AlphaFadeValue > 0.0f)
        {
            AlphaFadeValue -= Mathf.Clamp01(Time.deltaTime / FadeInTime);
            if (AlphaFadeValue < 0.0f)
            {
                AlphaFadeValue = 0.0f;
            }
            else
            {
                GUI.color = new Color(0, 0, 0, AlphaFadeValue);
                GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), FadeInTexture);
                return;
            }
        }

        // We can turn on the render object so we can render the on-screen menu
        if (GUIRenderObject != null)
        {
            if (ScenesVisible ||
                ShowVRVars ||
                Crosshair.IsCrosshairVisible() ||
                RiftPresentTimeout > 0.0f ||
                DeviceDetectionTimeout > 0.0f ||
                VisionGuide.GetFadeAlphaValue() > 0.0f)
            {
                GUIRenderObject.SetActive(true);
            }
            else
            {
                GUIRenderObject.SetActive(false);
            }
        }

        //***
        // Set the GUI matrix to deal with portrait mode
        Vector3   scale = Vector3.one;
        Matrix4x4 svMat = GUI.matrix;         // save current matrix

        // substitute matrix - only scale is altered from standard
        GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);

        // Cache current active render texture
        RenderTexture previousActive = RenderTexture.active;

        // if set, we will render to this texture
        if (GUIRenderTexture != null)
        {
            RenderTexture.active = GUIRenderTexture;
            GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 0.0f));
        }

        // Update OVRGUI functions (will be deprecated eventually when 2D renderingc
        // is removed from GUI)
        GuiHelper.SetFontReplace(FontReplace);

        // If true, we are displaying information about the Rift not being detected
        // So do not show anything else
        if (GUIShowRiftDetected() != true)
        {
            GUIShowLevels();
            GUIShowVRVariables();
        }

        // The cross-hair may need to go away at some point, unless someone finds it
        // useful
        Crosshair.OnGUICrosshair();

        // Since we want to draw into the main GUI that is shared within the MainMenu,
        // we call the OVRVisionGuide GUI function here
        VisionGuide.OnGUIVisionGuide();

        // Restore active render texture
        RenderTexture.active = previousActive;

        // ***
        // Restore previous GUI matrix
        GUI.matrix = svMat;
    }
Esempio n. 5
0
    void OnGUI()
    {
        // Important to keep from skipping render events
        if (Event.current.type != EventType.Repaint)
        {
            return;
        }

        // Fade in screen
//		if(AlphaFadeValue > 0.0f)
//		{
//              AlphaFadeValue -= Mathf.Clamp01(Time.deltaTime / FadeInTime);
//			if(AlphaFadeValue < 0.0f)
//			{
//				AlphaFadeValue = 0.0f;
//			}
//			else
//			{
//				GUI.color = new Color(0, 0, 0, AlphaFadeValue);
//                  GUI.DrawTexture( new Rect(0, 0, Screen.width, Screen.height ), FadeInTexture );
//				return;
//			}
//		}

        // We can turn on the render object so we can render the on-screen menu
        if (GUIRenderObject != null)
        {
            if (delayedShow || showMagStatus ||
                ((magCal.Disabled() == false) && (magCal.Ready() == false)))
            {
                GUIRenderObject.SetActive(true);
            }
            else
            {
                GUIRenderObject.SetActive(false);
            }
        }

        // Set the GUI matrix to deal with portrait mode
        Vector3 scale = Vector3.one;

        if (CameraController.PortraitMode == true)
        {
            float h = OVRDevice.HResolution;
            float v = OVRDevice.VResolution;
            scale.x = v / h;                  // calculate hor scale
            scale.y = h / v;                  // calculate vert scale
        }
        Matrix4x4 svMat = GUI.matrix;         // save current matrix

        // substitute matrix - only scale is altered from standard
        GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);

        // Cache current active render texture
        RenderTexture previousActive = RenderTexture.active;

        // if set, we will render to this texture
        if (GUIRenderTexture != null)
        {
            RenderTexture.active = GUIRenderTexture;
            GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 0.0f));
        }

        // Update OVRGUI functions (will be deprecated eventually when 2D renderingc
        // is removed from GUI)
        GuiHelper.SetFontReplace(textFont);

        if (showMagStatus || delayedShow || (magCal.Disabled() == false) && (magCal.Ready() == false))
        {
            // Print out auto mag correction state
            magCal.GUIMagYawDriftCorrection(VRVarsSX, VRVarsSY, VRVarsWidthX, VRVarsWidthY,
                                            ref GuiHelper);
        }

        // Restore active render texture
        RenderTexture.active = previousActive;

        // ***
        // Restore previous GUI matrix
        GUI.matrix = svMat;
    }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     ovrGui = new OVRGUI();
     ovrGui.SetCameraController(ref cameraController);
     ovrGui.SetFontReplace(timeFont);
 }
Esempio n. 7
0
    void OnGUI()
    {
        // Important to keep from skipping render events
        if (Event.current.type != EventType.Repaint)
        {
            return;
        }

        // We can turn on the render object so we can render the on-screen menu
        if (GUIRenderObject != null)
        {
            GUIRenderObject.SetActive(true);

            /*   if (ScenesVisible || ShowVRVars || Crosshair.IsCrosshairVisible() ||
             *      RiftPresentTimeout > 0.0f || DeviceDetectionTimeout > 0.0f ||
             *      ((MagCal.Disabled () == false) && (MagCal.Ready () == false))
             *      )
             *      GUIRenderObject.SetActive(true);
             *      else
             * GUIRenderObject.SetActive(false);*/
        }
        //***
        // Set the GUI matrix to deal with portrait mode
        Vector3 scale = Vector3.one;

        if (CameraController.PortraitMode == true)
        {
            float h = OVRDevice.HResolution;
            float v = OVRDevice.VResolution;
            scale.x = v / h;                  // calculate hor scale
            scale.y = h / v;                  // calculate vert scale
        }
        Matrix4x4 svMat = GUI.matrix;         // save current matrix

        // substitute matrix - only scale is altered from standard
        GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);

        // Cache current active render texture
        RenderTexture previousActive = RenderTexture.active;

        // if set, we will render to this texture
        if (GUIRenderTexture != null)
        {
            RenderTexture.active = GUIRenderTexture;
            GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 0.0f));
        }

        // Update OVRGUI functions (will be deprecated eventually when 2D renderingc
        // is removed from GUI)
        GuiHelper.SetFontReplace(FontReplace);

        if (CameraController != null)
        {
            /* ***************************************************  */
            /* ******* PLACE YOUR GUI CODE BELOW ******* */

            // Text
            //GuiHelper.StereoBox(525, 150, 100, 20, ref healthString, Color.red);
            //GuiHelper.StereoBox(525, 175, 100, 20, ref staminaString, Color.green);
            GuiHelper.StereoDrawTexture(525, 150, (int)healthBarLength, 15, ref healthBar, Color.gray);
            GuiHelper.StereoDrawTexture(525, 175, (int)staminaBarLength, 15, ref staminaBar, Color.gray);
            GuiHelper.StereoBox(775, 150, 50, 20, ref scoreString, Color.white);
            GuiHelper.StereoBox(775, 350, 50, 20, ref timeString, Color.white);

            // Labels
            GuiHelper.StereoDrawTexture(450, 150, 75, 20, ref healthIcon, Color.gray);
            GuiHelper.StereoDrawTexture(450, 175, 75, 20, ref staminaIcon, Color.gray);
            GuiHelper.StereoDrawTexture(640, 175, 75, 20, ref bubblesIcon, Color.gray);
            GuiHelper.StereoDrawTexture(720, 147, 40, 25, ref scoreIcon, Color.gray);
            GuiHelper.StereoDrawTexture(720, 347, 40, 25, ref timeIcon, Color.gray);

            // Bubbles
            displayBubbles();

            // Power-ups
            displayPowerUpIcons();
            /* ******************************************************* */
        }

        // Restore active render texture
        RenderTexture.active = previousActive;

        // ***
        // Restore previous GUI matrix
        GUI.matrix = svMat;
    }