示例#1
0
 void Update()
 {
     // Update the menu state if it needs to suddenly open or close
     if (!dummyParent && IsButtonClicked())
     {
         SetMenuLocation();
         if (IsMenuInFOV())
         {
             dummyParent          = (ClickMenuIcon)Instantiate(menuIconPrefab, transform);
             dummyParent.menuRoot = this;
             ClickMenuIcon.ShowMenu(this, menuTree.tree.Root, dummyParent,
                                    menuCenter, menuOrientation, iconScale);
             dummyParent.SetDummy();
             if (OnMenuOpened != null)
             {
                 OnMenuOpened.Invoke();
             }
         }
     }
     else if ((GvrControllerInput.ClickButtonDown && !selected) ||
              IsPointingAway())
     {
         CloseAll();
     }
     else if (dummyParent && GvrControllerInput.AppButtonUp)
     {
         MakeSelection(null);
         dummyParent.DeepestMenu().ShowParentMenu();
     }
 }
        void Update()
        {
            // Shorten laser when menus are open
            if (dummyParent)
            {
                float newDist = laserPointer.maxReticleDistance - reticleDelta;
                laserPointer.maxReticleDistance = Mathf.Max(newDist, menuDistance * POINTER_DISTANCE_SCALE);
            }

            // Update the menu state if it needs to suddenly open or close
            if (!dummyParent && IsButtonClicked())
            {
                SetMenuLocation();
                if (IsMenuInFOV())
                {
                    reticleDistance      = laserPointer.maxReticleDistance;
                    dummyParent          = (ClickMenuIcon)Instantiate(menuIconPrefab, transform);
                    dummyParent.menuRoot = this;
                    ClickMenuIcon.OpenMenu(this, menuTree.tree.Root, dummyParent,
                                           menuCenter, menuOrientation, 0.1f);
                    dummyParent.SetDummy();
                    if (OnMenuOpened != null)
                    {
                        OnMenuOpened.Invoke();
                    }
                }
            }
            else if ((GvrController.ClickButtonDown && !selected) ||
                     IsPointingAway())
            {
                CloseAll();
            }
            else if (dummyParent && GvrController.AppButtonUp)
            {
                MakeSelection(-1);
                dummyParent.DeepestMenu().CloseSubMenu();
            }
        }