Ejemplo n.º 1
0
        void CreateMenu()
        {
            if (menuOptions != null)
            {
                menuOptions.Clear();
            }
            else
            {
                menuOptions = new Dictionary <string, MenuOption>();
            }

            Vector3 position = InitialPosition;

            position.x += 50.0f;

            for (int i = options.Count - 1; i >= 0; i--)
            {
                MenuOption option = options[i];
                if (!option.isSpacer)
                {
                    option.GameObject = CreateMenuOption(option.name, option.label, position);
                    menuOptions.Add(option.name, option);
                }
                position.y += (float)ElementHeight;
            }
        }
Ejemplo n.º 2
0
        void UnSelectChild(string child)
        {
            MenuOption menuOption = menuOptions[child];

            if (menuOption != null)
            {
                Text selectedText = menuOption.GameObject.GetComponent <Text>();
                selectedText.fontStyle = FontStyle.Normal;
            }
        }
Ejemplo n.º 3
0
        void RunAction(string optionName)
        {
            MenuOption menuOption = menuOptions[optionName];

            if (menuOption.destination != null)
            {
                menuOption.destination.transform.gameObject.SetActive(true);
                transform.parent.gameObject.SetActive(false);
            }

            List <IMenuEventHandler> implementors = GameObjectFindHelper.FindGameObjectWithInterface <IMenuEventHandler>();

            for (int i = 0, length = implementors.Count; i < length; i++)
            {
                MonoBehaviour implementor = (MonoBehaviour)implementors[i];
                ExecuteEvents.Execute <IMenuEventHandler>(implementor.gameObject, null,
                                                          (handler, eventData) => { handler.MenuSelected(menuOption.name); });
            }
        }
Ejemplo n.º 4
0
        void SelectChild(string child)
        {
            MenuOption menuOption = menuOptions[child];

            if (menuOption != null)
            {
                Text selectedText = menuOption.GameObject.GetComponent <Text>();
                selectedText.fontStyle = FontStyle.Bold;

                RectTransform rectTransform = selectedMenuGameObject.GetComponent <RectTransform>();
                rectTransform.SetParent(menuOption.GameObject.transform, false);
                rectTransform.localPosition = new Vector3(-25.0f, 15.0f, 0.0f);
                rectTransform.anchorMin     = rectTransform.anchorMax = new Vector2(0.0f, 0.5f);
                rectTransform.sizeDelta     = new Vector2(20.0f, 20.0f);
                rectTransform.localScale    = Vector3.one;

                currentSelectedChild = menuOption.name;
            }
        }