예제 #1
0
    private GameObject createTwoButtonOption(string label, buttonHandlerType up, buttonHandlerType down, buttonHandlerType apply)
    {
        GameObject g = Instantiate(twoButtonTemplate);

        g.transform.Find("LabelText").GetComponent <TextMesh> ().text = label;
        addToScroll(g);

        GameObject icon;

        icon = g.transform.Find("LeftSymbol").gameObject;
        if (decrementIcon != null)
        {
            icon.GetComponent <MeshRenderer> ().material.mainTexture = decrementIcon;
        }
        icon = g.transform.Find("RightSymbol").gameObject;
        if (incrementIcon != null)
        {
            icon.GetComponent <MeshRenderer> ().material.mainTexture = incrementIcon;
        }

        addItemAsMenuOption(g.gameObject.transform.Find("LeftSymbol").gameObject, up);
        addItemAsMenuOption(g.gameObject.transform.Find("RightSymbol").gameObject, down);
        addItemAsMenuOption(g.gameObject.transform.Find("ApplySymbol").gameObject, apply);

        return(g);
    }
예제 #2
0
    // Add a button to the menu, using a previously created game object. Specifies the
    // handler invoked when the button is pressed.
    public GameObject addItemAsMenuOption(GameObject menuOption, buttonHandlerType handler)
    {
        if (menu == null)
        {
            initializeMenu();
        }

        MenuItem mi = new MenuItem();

        mi.button  = menuOption;
        mi.handler = handler;
        menuItems.Add(mi);

        return(menuOption);
    }
예제 #3
0
    // Add a button to the menu, by instantiating the button template, and setting the text
    // field to the string specified. The position of the menu button is also provided.
    public GameObject addMenuOption(string option, Vector3 position, buttonHandlerType handler, buttonPointerOverHandler pointerResponse = null, buttonScrollHandler scrollResponse = null)
    {
        if (menu == null)
        {
            initializeMenu();
        }

        // Create an scene object for the button.
        GameObject menuOption = Instantiate(menuButtonTemplate);

        menuOption.transform.localPosition = position;
        menuOption.transform.SetParent(menu.transform, false);
        // Set the label, if possible.
        setLabel(menuOption, option);

        // Add the object to the menu.
        return(addItemAsMenuOption(menuOption, handler, pointerResponse, scrollResponse));
    }
예제 #4
0
    // Add a button to the menu, using a previously created game object. Specifies the
    // handler invoked when the button is pressed. The handler will be called with
    // initialize set to true, so must respond by setting appearance and not calling its
    // handler.
    // The pointer response function provides some form of feedback when the pointer hovers
    // over the button.
    public GameObject addItemAsMenuOption(GameObject menuOption, buttonHandlerType handler, buttonPointerOverHandler pointerResponse = null, buttonScrollHandler scrollResponse = null)
    {
        if (menu == null)
        {
            initializeMenu();
        }

        MenuItem mi = new MenuItem();

        mi.button             = menuOption;
        mi.handler            = handler;
        mi.pointerOverHandler = pointerResponse;
        mi.scrollHandler      = scrollResponse;
        menuItems.Add(mi);

        handler(null, null, mi.button, null, true);

        return(menuOption);
    }
예제 #5
0
    // Add a button to the menu, by instantiating the button template, and setting the text
    // field to the string specified. The position of the menu button is also provided.
    public GameObject addMenuOption(string option, Vector3 position, buttonHandlerType handler)
    {
        if (menu == null)
        {
            initializeMenu();
        }

        // Create an scene object for the button.
        GameObject menuOption = Instantiate(menuButtonTemplate);

        menuOption.transform.localPosition = position;
        menuOption.transform.SetParent(menu.transform, false);
        // Set the label, if possible.
        if (menuOption.GetComponentInChildren <TextMesh> () != null)
        {
            menuOption.GetComponentInChildren <TextMesh> ().text = option;
        }

        // Add the object to the menu.
        return(addItemAsMenuOption(menuOption, handler));
    }
예제 #6
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));
 }
예제 #7
0
 // Create a handler for toggle/checkbox interactions. This accepts two handlers, one to respond
 // when the toggle is set, the other when it is reset.
 private void toggleButton(ToggleVariable toggleVariable, string onString, string offString, buttonHandlerType handlerOn, buttonHandlerType handlerOff, 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 = checkOn;
         }
         if (handlerOn != null)
         {
             handlerOn(controller, controllerObject, button, avatar, initialize);
         }
     }
     else
     {
         setLabel(button, offString);
         GameObject icon = button.transform.Find("CheckOptionSymbol").gameObject;
         if (icon != null)
         {
             icon.GetComponent <MeshRenderer> ().material.mainTexture = checkOff;
         }
         if (handlerOff != null)
         {
             handlerOff(controller, controllerObject, button, avatar, initialize);
         }
     }
 }