コード例 #1
0
    // GUIShowLevels
    void GUIShowLevels()
    {
        if (ScenesVisible == true)
        {
            // Darken the background by rendering fade texture
            GUI.color = new Color(0, 0, 0, 0.5f);
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), FadeInTexture);
            GUI.color = Color.white;

            if (LoadingLevel == true)
            {
                string loading = "LOADING...";
                GuiHelper.StereoBox(StartX, StartY, WidthX, WidthY, ref loading, Color.yellow);
                return;
            }

            for (int i = 0; i < SceneNames.Length; i++)
            {
                Color c;
                if (i == CurrentLevel)
                {
                    c = Color.yellow;
                }
                else
                {
                    c = Color.black;
                }

                int y = StartY + (i * StepY);

                GuiHelper.StereoBox(StartX, y, WidthX, WidthY, ref SceneNames[i], c);
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// GUIs the mag yaw drift correction.
    /// </summary>
    /// <param name="xLoc">X location.</param>
    /// <param name="yLoc">Y location.</param>
    /// <param name="xWidth">X width.</param>
    /// <param name="yWidth">Y width.</param>
    /// <param name="guiHelper">GUI helper.</param>
    public void GUIMagYawDriftCorrection(int xLoc, int yLoc,
                                         int xWidth, int yWidth,
                                         ref OVRGUI guiHelper)
    {
        string strMagCal = "";
        Color  c         = Color.red;
        int    xloc      = xLoc;
        int    xwidth    = xWidth;

        switch (MagCalState)
        {
        case (MagCalibrationState.MagUncalibrated):
            strMagCal = "Mag Uncalibrated";
            break;

        case (MagCalibrationState.MagDisabled):
            strMagCal = "Mag Calibration OFF";
            break;

        case (MagCalibrationState.MagReady):
            strMagCal = "Mag Correction ON";
            c         = Color.red;
            break;
        }

        guiHelper.StereoBox(xloc, yLoc, xwidth, yWidth, ref strMagCal, c);
    }
コード例 #3
0
    // GUIMagYawDriftCorrection
    public void GUIMagYawDriftCorrection(int xLoc, int yLoc,
                                         int xWidth, int yWidth,
                                         ref OVRGUI guiHelper)
    {
        string strMagCal = "";
        Color  c         = Color.red;
        int    xloc      = xLoc;
        int    xwidth    = xWidth;

        switch (MagCalState)
        {
        case (MagCalibrationState.MagDisabled):
            strMagCal = "Mag Calibration OFF";
            break;

        case (MagCalibrationState.MagManualGetReady):
            strMagCal = "Manual Calibration: Look Forward, Press 'Z'..";
            c         = Color.white;
            xloc     -= 40;
            xwidth   += 150;
            break;

        case (MagCalibrationState.MagCalibrating):
            if (MagCalTimerFlash > 0.2f)
            {
                FormatCalibratingString(ref strMagCal);
            }

            MagCalTimerFlash -= Time.deltaTime;
            if (MagCalTimerFlash < 0.0f)
            {
                MagCalTimerFlash += 0.5f;
            }

            c       = Color.white;
            xloc   -= 40;
            xwidth += 150;
            break;

        case (MagCalibrationState.MagCalibrated):
            strMagCal         = "Mag Calibrated";
            MagCalTimerFlash -= Time.deltaTime;
            if (MagCalTimerFlash < 0.0f)
            {
                MagCalTimerFlash += 0.5f;
            }

            c = Color.yellow;
            break;

        case (MagCalibrationState.MagReady):
            if (OVRDeviceImposter.IsMagYawCorrectionInProgress(0) == true)
            {
                if (MagCalTimerFlash > 0.2f)
                {
                    strMagCal = "Mag CORRECTING...";
                    strMagCal = System.String.Format("Mag CORRECTING (deg)... {0:F3}",
                                                     OVRDeviceImposter.GetYawErrorAngle(0));
                }

                MagCalTimerFlash -= Time.deltaTime;
                if (MagCalTimerFlash < 0.0f)
                {
                    MagCalTimerFlash += 0.5f;
                }

                xloc   -= 40;
                xwidth += 150;

                c = Color.red;
            }
            else
            {
                strMagCal = "Mag Correction ON";
                c         = Color.green;
            }

            break;
        }

        guiHelper.StereoBox(xloc, yLoc, xwidth, yWidth, ref strMagCal, c);
    }
コード例 #4
0
    /// <summary>
    /// GUIs the mag yaw drift correction.
    /// </summary>
    /// <param name="xLoc">X location.</param>
    /// <param name="yLoc">Y location.</param>
    /// <param name="xWidth">X width.</param>
    /// <param name="yWidth">Y width.</param>
    /// <param name="guiHelper">GUI helper.</param>
    public void GUIMagYawDriftCorrection(int xLoc, int yLoc, 
        int xWidth, int yWidth,
        ref OVRGUI guiHelper)
    {
        string strMagCal = "";
        Color c = Color.red;
        int xloc = xLoc;
        int xwidth = xWidth;

        switch(MagCalState)
        {
        case(MagCalibrationState.MagUncalibrated):
            strMagCal = "Mag Uncalibrated";
            break;

        case(MagCalibrationState.MagDisabled):
            strMagCal = "Mag Calibration OFF";
            break;

        case(MagCalibrationState.MagReady):
            strMagCal = "Mag Correction ON";
            c = Color.red;
            break;
        }

        guiHelper.StereoBox (xloc, yLoc, xwidth, yWidth, ref strMagCal, c);
    }
コード例 #5
0
    // GUIMagYawDriftCorrection
    public void GUIMagYawDriftCorrection(int xLoc, int yLoc, 
										 int xWidth, int yWidth, 
										 ref OVRGUI guiHelper)
    {
        string strMagCal = "";
        Color c = Color.red;
        int xloc = xLoc;
        int xwidth = xWidth;

        switch(MagCalState)
        {
        case(MagCalibrationState.MagDisabled):
            strMagCal = "Mag Calibration OFF";
            break;

        case(MagCalibrationState.MagManualGetReady):
            strMagCal = "Manual Calibration: Look Forward, Press 'Z'..";
            c = Color.white;
            xloc -= 75;
            xwidth += 150;
            break;

        case(MagCalibrationState.MagCalibrating):
            if(MagCalTimerFlash > 0.2f)
                FormatCalibratingString(ref strMagCal);

            MagCalTimerFlash -= Time.deltaTime;
            if(MagCalTimerFlash < 0.0f)
                MagCalTimerFlash += 0.5f;

            c = Color.white;
            xloc -= 75;
            xwidth += 150;
            break;

        case(MagCalibrationState.MagReady):
            if(OVRDevice.IsMagYawCorrectionInProgress(0) == true)
            {
                if(MagCalTimerFlash > 0.2f)
                {
                    strMagCal = "Mag CORRECTING...";
                }

                MagCalTimerFlash -= Time.deltaTime;
                if(MagCalTimerFlash < 0.0f)
                    MagCalTimerFlash += 0.5f;

                xloc -= 75;
                xwidth += 150;

                c = Color.green;
            }
            else
            {
                strMagCal = "Mag Correction ON";
                c = Color.red;
            }

            break;
        }

        guiHelper.StereoBox (xloc, yLoc, xwidth, yWidth, ref strMagCal, c);
    }
コード例 #6
0
ファイル: GUIController.cs プロジェクト: mimlowe/Aerosolt
    //Called in OVRMainMenu.cs
    public void OculusGUI(ref OVRGUI GuiHelper)
    {
        if (!oculusEnabled) return;

        //In-game UI

        //Reticule (replaced by 3d object)
        //GuiHelper.StereoDrawTexture((int)(screenWidth / 2 - reticuleSize / 2), (int)(screenHeight / 2 - reticuleSize / 2), (int)reticuleSize, (int)reticuleSize, ref reticule, Color.white);

        //Health
        string hp = Player.getHP().ToString("F0");
        GuiHelper.StereoBox((int)screenWidth / 2 - 30, (int)screenHeight / 4 - 10, 60, 20, ref hp, Color.red);

        //Ammo
        string ammo = Player.getAmmo().ToString("F0");
        GuiHelper.StereoBox((int)screenWidth / 2 - 30, (int)screenHeight / 4 * 3 - 10 - 40, 60, 20, ref ammo, Color.blue);

        //Framerate
        if (showFramerate) GUI.Label(new Rect(600, 240, 400, 400), (1 / Time.deltaTime).ToString("F4"));

        if (showMinimap) {
            GUI.color = minimapTint;
            //Minimap
            GuiHelper.StereoDrawTexture((int)(minimapLocation.x), (int)(minimapLocation.y), (int)minimapLocation.width, (int)minimapLocation.height, ref minimap, Color.white);
            GUI.color = Color.white;

            //Indicator
            Rect indicatorLocation = new Rect(minimapLocation.xMin + minimapLocation.width / 2 + (player.transform.position.x / gameworldSize * minimapSize / 2) - indicatorSize / 2, minimapLocation.yMin + minimapLocation.height / 2 - (player.transform.position.z / gameworldSize * minimapSize / 2) - indicatorSize / 2, indicatorSize, indicatorSize);
            //Rect pivot = new Rect();
            //GuiHelper.CalcPositionAndSize(minimapLocation.xMin + minimapLocation.width / 2 + (player.transform.position.x / gameworldSize * minimapSize / 2), minimapLocation.yMin + minimapLocation.height / 2 - (player.transform.position.z / gameworldSize * minimapSize / 2), indicatorSize, indicatorSize, ref pivot);
            //Matrix4x4 backup = GUI.matrix;
            //GUIUtility.RotateAroundPivot(player.transform.eulerAngles.y, new Vector2(pivot.x, pivot.y));
            GuiHelper.StereoDrawTexture((int)(indicatorLocation.x), (int)(indicatorLocation.y), (int)indicatorLocation.width, (int)indicatorLocation.height, ref minimapIndicator, Color.white);
            //GUI.matrix = backup;
        }

        //Overlay menu
        if (showingMenu) {
            GuiHelper.StereoDrawTexture(0, 0, (int)screenWidth, (int)screenHeight, ref bg, Color.white);

            switch (menuSelection) {
            case 0:
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 60), (int)menuItem.width, (int)menuItem.height, ref menuOptions[0], Color.red);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 20), (int)menuItem.width, (int)menuItem.height, ref menuOptions[1], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 20), (int)menuItem.width, (int)menuItem.height, ref menuOptions[2], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 60), (int)menuItem.width, (int)menuItem.height, ref menuOptions[3], Color.white);
                break;

            case 1:
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 60), (int)menuItem.width, (int)menuItem.height, ref menuOptions[0], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 20), (int)menuItem.width, (int)menuItem.height, ref menuOptions[1], Color.red);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 20), (int)menuItem.width, (int)menuItem.height, ref menuOptions[2], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 60), (int)menuItem.width, (int)menuItem.height, ref menuOptions[3], Color.white);
                break;

            case 2:
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 60), (int)menuItem.width, (int)menuItem.height, ref menuOptions[0], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 20), (int)menuItem.width, (int)menuItem.height, ref menuOptions[1], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 20), (int)menuItem.width, (int)menuItem.height, ref menuOptions[2], Color.red);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 60), (int)menuItem.width, (int)menuItem.height, ref menuOptions[3], Color.white);
                break;

            case 3:
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 60), (int)menuItem.width, (int)menuItem.height, ref menuOptions[0], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 20), (int)menuItem.width, (int)menuItem.height, ref menuOptions[1], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 20), (int)menuItem.width, (int)menuItem.height, ref menuOptions[2], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 60), (int)menuItem.width, (int)menuItem.height, ref menuOptions[3], Color.red);
                break;
            }
        } else if (showingDeathScreen) {
            //GUI.Box(new Rect((int)0, (int)0, (int)screenWidth, (int)screenHeight), "", background);
            GuiHelper.StereoDrawTexture(0, 0, (int)screenWidth, (int)screenHeight, ref bg, Color.white);

            GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y - 80), (int)menuItem.width, (int)menuItem.height, ref deathString, Color.red);

            switch (menuSelection) {
            case 0:
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 0), (int)menuItem.width, (int)menuItem.height, ref deathOptions[0], Color.red);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 40), (int)menuItem.width, (int)menuItem.height, ref deathOptions[1], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 80), (int)menuItem.width, (int)menuItem.height, ref deathOptions[2], Color.white);
                break;

            case 1:
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 0), (int)menuItem.width, (int)menuItem.height, ref deathOptions[0], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 40), (int)menuItem.width, (int)menuItem.height, ref deathOptions[1], Color.red);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 80), (int)menuItem.width, (int)menuItem.height, ref deathOptions[2], Color.white);
                break;

            case 2:
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 0), (int)menuItem.width, (int)menuItem.height, ref deathOptions[0], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 40), (int)menuItem.width, (int)menuItem.height, ref deathOptions[1], Color.white);
                GuiHelper.StereoBox((int)menuItem.x, (int)(menuItem.y + 80), (int)menuItem.width, (int)menuItem.height, ref deathOptions[2], Color.red);
                break;
            }
        }
    }
コード例 #7
0
    void OnGUI()
    {
        if (showOverlays)
        {
            Event e = Event.current;

            if (e.isKey && e.type == EventType.KeyDown && e.keyCode == KeyCode.DownArrow)
            {
                currentStep++;
            }
            if (e.isKey && e.type == EventType.KeyDown && e.keyCode == KeyCode.UpArrow)
            {
                currentStep--;
            }

            if (currentStep < 0 || (currentStep > instructionSteps.Length - 1))
            {
                currentStep = 0;
            }

            //print (currentStep);

            if (e.keyCode == KeyCode.Return)
            {
                if (allowedRooms.Contains(roomNumber))
                {
                    Application.LoadLevel("SortingPuzzle");
                }
                else
                {
                    roomNumber = "";
                }

                //hideControls = true;
                //print("room number submitted: " + roomNumber);
            }

            if (!hideControls)
            {
                GUI.SetNextControlName("RoomInput");
                roomNumber = GUI.TextField(new Rect(300, 350, 200, 20), roomNumber, 25);
                GUI.FocusControl("RoomInput");

                string instructionString = "";

                int finalStep = (currentStep + 3 < instructionSteps.Length) ? currentStep + 3 : instructionSteps.Length;

                for (int i = currentStep; i < finalStep; i++)
                {
                    instructionString += "\n";
                    instructionString += instructionSteps[i];
                }

                ovrGui.StereoBox(150, 200, 600, 200, ref instructionString, Color.white);
            }

            if (showOverlays)
            {
                switchIndicator.renderer.enabled = true;
            }
            else
            {
                switchIndicator.renderer.enabled = false;
            }

            string timeString;

            if (GetTimeRemaining() > 0)
            {
                timeString = GetTimeRemaining().ToString("0.000");
            }
            else
            {
                timeString = "FAIL";
            }
            ovrGui.StereoBox(300, 450, 100, 40, ref timeString, timeColor);
        }
    }
コード例 #8
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;
    }
コード例 #9
0
    // GUIMagYawDriftCorrection
    public void GUIMagYawDriftCorrection(int xLoc, int yLoc,
                                         int xWidth, int yWidth,
                                         ref OVRGUI guiHelper)
    {
        string strMagCal = "";
        Color  c         = Color.red;
        int    xloc      = xLoc;
        int    xwidth    = xWidth;

        switch (MagCalState)
        {
        case (MagCalibrationState.MagDisabled):
            strMagCal = "Mag Calibration OFF";
            break;

        case (MagCalibrationState.MagManualGetReady):
            strMagCal = "Manual Calibration: Look Forward, Press " + manualCalibrationKey.ToString();
            c         = Color.white;
            xloc     -= 75;
            xwidth   += 150;
            break;

        case (MagCalibrationState.MagCalibrating):
            if (MagCalTimerFlash > 0.2f)
            {
                FormatCalibratingString(ref strMagCal);
            }

            MagCalTimerFlash -= Time.deltaTime;
            if (MagCalTimerFlash < 0.0f)
            {
                MagCalTimerFlash += 0.5f;
            }

            c       = Color.white;
            xloc   -= 75;
            xwidth += 150;
            break;

        case (MagCalibrationState.MagReady):
            if (OVRDevice.IsMagYawCorrectionInProgress(0) == true)
            {
                if (MagCalTimerFlash > 0.2f)
                {
                    strMagCal = "Mag CORRECTING...";
                }

                MagCalTimerFlash -= Time.deltaTime;
                if (MagCalTimerFlash < 0.0f)
                {
                    MagCalTimerFlash += 0.5f;
                }

                xloc   -= 75;
                xwidth += 150;

                c = Color.green;
            }
            else
            {
                strMagCal = "Mag Correction ON";
                c         = Color.red;
            }

            break;
        }

        guiHelper.StereoBox(xloc, yLoc, xwidth, yWidth, ref strMagCal, c);
    }
コード例 #10
0
    void OnGUI()
    {
        if (!CheckVictory())
        {
            timeString = (timePerLevel - Time.timeSinceLevelLoad).ToString("0.000");
        }
        else
        {
            string win = "WIN";
            ovrGui.StereoBox(200, 500, 200, 60, ref win, Color.red);
            if (winTime == 0)
            {
                winTime = Time.time;
            }

            if (winTime > 0 && (Time.time - winTime > 2.0f))
            {
                Application.LoadLevel("cameraIntegration");
            }
        }


        if (CheckFailure())
        {
            string fail = "FAIL";
            ovrGui.StereoBox(200, 500, 200, 60, ref fail, Color.red);
        }
        else
        {
            if (winTime == 0)
            {
                ovrGui.StereoBox(200, 500, 200, 60, ref timeString, timeColor);
            }

            Event e = Event.current;
            if (e.isKey && e.keyCode == KeyCode.RightArrow && movePercent == 1)
            {
                NextCube();
            }
            else if (e.isKey && Input.GetKeyDown(KeyCode.Space) && movePercent == 1)
            {
                if (!userSort.Contains(cubes[currentCube]))
                {
                    userSort.Add(cubes[currentCube]);
                }
                else
                {
                    userSort.Remove(cubes[currentCube]);
                    userSort.Add(cubes[currentCube]);
                }


                int i = 0;
                foreach (GameObject item in userSort)
                {
                    item.GetComponent <BlinkySorty>().GoTo(lineHead.transform.position + (Vector3.left * 2 * i));
                    i++;
                }

                //NextCube();
            }
        }
    }