PlatformUIGlobalMenu() public static method

public static PlatformUIGlobalMenu ( ) : void
return void
Beispiel #1
0
    /// <summary>
    /// Show the platform UI global menu
    /// </summary>
    void ShowGlobalMenu()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        Debug.Log("[PlatformUI-Global] Showing @ " + Time.time);
        OVRManager.PlatformUIGlobalMenu();
#endif
    }
Beispiel #2
0
    /// <summary>
    /// Processes input and handles menu interaction
    /// as per the Unity integration doc, the back button responds to "mouse 1" button down/up/etc
    /// </summary>
    void Update()
    {
        if (!isVisible)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                CancelInvoke("DelayedShowMenu");
                if (Time.realtimeSinceStartup < (homeButtonDownTime + doubleTapDelay))
                {
                    // reset so the menu doesn't pop up after resetting orientation
                    homeButtonDownTime = 0f;
                    // reset the HMT orientation
                    //OVRManager.display.RecenterPose();
                }
                else
                {
                    homeButtonDownTime = Time.realtimeSinceStartup;
                }
            }
            else if (Input.GetKey(KeyCode.Escape) && ((Time.realtimeSinceStartup - homeButtonDownTime) >= longPressDelay))
            {
                Debug.Log("[PlatformUI] Showing @ " + Time.time);
                // reset so something else doesn't trigger afterwards
                Input.ResetInputAxes();
                homeButtonDownTime = 0.0f;
                CancelInvoke("DelayedShowMenu");

                OVRManager.PlatformUIGlobalMenu();
            }
            else if (Input.GetKeyUp(KeyCode.Escape))
            {
                float elapsedTime = (Time.realtimeSinceStartup - homeButtonDownTime);
                if (elapsedTime < longPressDelay)
                {
                    if (elapsedTime >= doubleTapDelay)
                    {
                        Show(true);
                    }
                    else
                    {
                        Invoke("DelayedShowMenu", (doubleTapDelay - elapsedTime));
                    }
                }
            }
        }
        else if (!isShowingOrHiding)
        {
            // menu is visible, check input
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                // back out of the menu
                Show(false);
            }
            else
            {
                // handle user gaze
                Ray ray = new Ray(cameraController.centerEyeAnchor.position, cameraController.centerEyeAnchor.forward);

                // find the active button
                HomeButton lastActiveButton = activeButton;
                activeButton = null;
                RaycastHit hit = new RaycastHit();
                for (int i = 0; i < buttons.Length; i++)
                {
                    if (buttons[i].GetComponent <Collider>().Raycast(ray, out hit, 100.0f))
                    {
                        activeButton = buttons[i];
                        if (activeButton != lastActiveButton)
                        {
                            // play highlight sound and anim
                            PlaySound(menuHighlightSound);
                            PlayAnim(buttons[i].name + highLightPrefix, true);
                        }
                        break;
                    }
                }
                if ((activeButton == null) && (lastActiveButton != null))
                {
                    // return to idle anim (in our case the default anim clip)
                    PlayAnim(menuIdleAnim, true);
                }
                if (activeButton != null)
                {
                    // check user tap on a button
                    if (Input.GetButtonDown(selectButtonName))
                    {
                        PlaySound(menuClickSound);
                        float delaySecs = PlayAnim(activeButton.name + selectPrefix) + 0.05f;
                        selectedCommand = activeButton.commandId;
                        // activate the menu item after the anim is done playing
                        Invoke("OnMenuItemPressed", delaySecs);
                    }
                }
            }
        }
    }