Пример #1
0
        private void CreateMenuItems(List <MenuItemUIModel> models, VerticalMenuSelectUI instance)
        {
            // Clear current menu items
            instance.container.DestroyChildren();
            instance.menuItems = new List <MenuItemUI>();

            // Create menu items
            int i = 0;

            foreach (MenuItemUIModel model in models)
            {
                MenuItemUI menuItem = MenuItemUI.Initialize(instance.menuItemPrefab, instance.container, model);

                menuItem.RectTransform.anchoredPosition = new Vector2(0, i * -menuItem.RectTransform.sizeDelta.y);
                if (i == focus)
                {
                    menuItem.Highlight();
                }
                else
                {
                    menuItem.UnHighlight();
                }

                instance.menuItems.Add(menuItem);

                i++;
            }
        }
Пример #2
0
 public static VerticalMenuSelectUI Initialize(
     VerticalMenuSelectUI prefab,
     List <MenuItemUIModel> models,
     bool cancelable    = false,
     string moveSound   = null,
     string selectSound = null,
     string cancelSound = null
     )
 {
     return(prefab._Initialize(prefab, models, cancelable, moveSound, selectSound, cancelSound) as VerticalMenuSelectUI);
 }
Пример #3
0
        protected override LinearMenuSelect _Initialize(
            LinearMenuSelect prefab,
            List <MenuItemUIModel> models,
            bool cancelable    = false,
            string moveSound   = null,
            string selectSound = null,
            string cancelSound = null
            )
        {
            VerticalMenuSelectUI instance = SpawnManager
                                            .SpawnCanvasElement(prefab.gameObject, 5)
                                            .GetComponentWithError <VerticalMenuSelectUI>();

            instance.cancelable = cancelable;

            instance.moveSound   = moveSound;
            instance.selectSound = selectSound;
            instance.cancelSound = cancelSound;

            CreateMenuItems(models, instance);

            return(instance);
        }