コード例 #1
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));
    }
コード例 #2
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);
    }