コード例 #1
0
 void ActOnButton()
 {
     //Toggle on and off. Some Buttons do not allow toggling off.
     if ((CurrentButton.isOn && CurrentButton.allowToggle) || !CurrentButton.isOn)
     {
         if (!CurrentButton.disabled)
         {
             CurrentButton.isOn = !CurrentButton.isOn;
             CurrentButton.ActOnRotator(CurrentButton.isOn);
         }
     }
 }
コード例 #2
0
        IEnumerator Rotate(bool isTouchPositive)
        {
            SetRotator(false);

            /*---The Old Button---*/
            CurrentButton.isEnlarging = false;
            Shirnk(CurrentButton);

            if (CurrentButton.isOn && CurrentButton.disableWhenRotatedAway)
            {
                CurrentButton.ActOnRotator(false);
            }

            ViveSR_Experience_IButton oldBtn = CurrentButton;

            /*--------------------*/

            /*---The New Button---*/
            CurrentButton = GetButtons(isTouchPositive, 1);

            //Enlarge
            CurrentButton.isShrinking = false;
            Enlarge(CurrentButton);

            //Set the target degree.
            targetY = localY + (360 / (int)MenuButton.MaxNum) * (isTouchPositive ? 1 : -1);

            CurrentButton.gameObject.transform.GetChild(0).transform.localScale *= 1.2f;

            while (isTouchPositive ? localY <targetY : localY> targetY)
            {
                localY += (isTouchPositive ? 1 : -1) * rotateSpeed * Time.deltaTime;
                transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, localY, transform.localEulerAngles.z);

                yield return(new WaitForEndOfFrame());
            }

            targetY = localY = (360 / IncludedBtns.Count) * CurrentButton.rotatorIdx;
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, targetY, transform.localEulerAngles.z);

            oldBtn.gameObject.transform.GetChild(0).transform.localScale = Vector3.one * 0.03f;

            AdjustUITransform();
            SetRotator(true);

            /*--------------------*/
        }