コード例 #1
0
 // Provides standard menu functions, but call a more advanced handler since the button knows more
 // information about itself.
 private void fileToggleButton(TreeNode n, ToggleVariable toggleVariable, string onString, string offString, fileButtonHandlerType handlerOn, fileButtonHandlerType handlerOff, Texture onIcon, Texture offIcon, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         toggleVariable.toggle = !toggleVariable.toggle;
     }
     if (toggleVariable.toggle)
     {
         setLabel(button, onString);
         GameObject icon = button.transform.Find("CheckOptionSymbol").gameObject;
         if (icon != null)
         {
             icon.GetComponent <MeshRenderer> ().material.mainTexture = onIcon;
         }
         if (handlerOn != null)
         {
             handlerOn(n, controller, controllerObject, button, avatar, initialize);
         }
     }
     else
     {
         setLabel(button, offString);
         GameObject icon = button.transform.Find("CheckOptionSymbol").gameObject;
         if (icon != null)
         {
             icon.GetComponent <MeshRenderer> ().material.mainTexture = offIcon;
         }
         if (handlerOff != null)
         {
             handlerOff(n, controller, controllerObject, button, avatar, initialize);
         }
     }
 }
コード例 #2
0
        public override IEnumerator Execute(GameObject target, IAction[] actions, int index)
        {
            canvasPanel.SetActive(true);


            text  = canvasPanel.GetComponentInChildren <Text>();
            image = canvasPanel.GetComponent <Image>();

            dropdown = canvasPanel.GetComponent <Dropdown>();

            slider = canvasPanel.GetComponent <SliderVariable>();

            toggle = canvasPanel.GetComponent <ToggleVariable>();

            button = canvasPanel.GetComponent <ButtonActions>();


            if (text != null)
            {
                float targetAlpha = alpha.GetValue(target);


                float currentAlpha = text.color.a;
                float startTime    = Time.unscaledTime;

                text.CrossFadeAlpha(targetAlpha, duration, false);
            }

            if (image != null)
            {
                float targetAlpha = alpha.GetValue(target);


                float currentAlpha = image.color.a;
                float startTime    = Time.unscaledTime;

                image.CrossFadeAlpha(targetAlpha, duration, false);
            }
            yield return(new WaitForSeconds(duration));

            float targetA = alpha.GetValue(target);

            if (targetA == 0)
            {
                if (dropdown != null)
                {
                    dropdown.interactable = false;
                    dropdown.enabled      = false;
                }
                if (slider != null)
                {
                    slider.interactable = false;
                    slider.enabled      = false;
                }
                if (toggle != null)
                {
                    toggle.interactable = false;
                    toggle.enabled      = false;
                }

                if (button != null)
                {
                    button.interactable = false;
                }

                canvasPanel.SetActive(false);
            }

            else if (targetA > 0)
            {
                if (dropdown != null)
                {
                    dropdown.interactable = true;
                    dropdown.enabled      = true;
                }
                if (slider != null)
                {
                    slider.interactable = true;
                    slider.enabled      = true;
                }
                if (toggle != null)
                {
                    toggle.interactable = true;
                    toggle.enabled      = true;
                }
                if (button != null)
                {
                    button.interactable = true;
                }

                canvasPanel.SetActive(true);
            }



            yield return(0);
        }
コード例 #3
0
 // A variation on the toggle handler that allows some extra information to be passed.
 buttonHandlerType fileToggleHandler(TreeNode n, ToggleVariable toggleVariable, string onString, string offString, fileButtonHandlerType handlerOn, fileButtonHandlerType handlerOff, Texture onIcon, Texture offIcon)
 {
     return((controller, controllerObject, button, avatar, initialize) => fileToggleButton(n, toggleVariable, onString, offString, handlerOn, handlerOff, onIcon, offIcon, controller, controllerObject, button, avatar, initialize));
 }
コード例 #4
0
 // Curry a toggle handler into a regular button handler, so that some of the parameters can be
 // provided when the button is set up.
 buttonHandlerType toggleHandler(ToggleVariable toggleVariable, string onString, string offString, buttonHandlerType handlerOn, buttonHandlerType handlerOff)
 {
     return((controller, controllerObject, button, avatar, initialize) => toggleButton(toggleVariable, onString, offString, handlerOn, handlerOff, controller, controllerObject, button, avatar, initialize));
 }