private void CreateMenuItems(List <MenuItemUIModel> models, HorizontalMenuSelectUI instance) { // Create menu items instance.container.DestroyChildren(); instance.menuItems = new List <MenuItemUI>(); int i = 0; foreach (MenuItemUIModel model in models) { MenuItemUI menuItem = MenuItemUI.Initialize(instance.menuItemPrefab, instance.container, model); menuItem.RectTransform.anchoredPosition = new Vector2(i * menuItem.RectTransform.sizeDelta.x, 0); if (i == focus) { menuItem.Highlight(); } else { menuItem.UnHighlight(); } instance.menuItems.Add(menuItem); i++; } }
public static HorizontalMenuSelectUI Initialize( HorizontalMenuSelectUI 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 HorizontalMenuSelectUI); }
protected override LinearMenuSelect _Initialize( LinearMenuSelect prefab, List <MenuItemUIModel> models, bool cancelable = false, string moveSound = null, string selectSound = null, string cancelSound = null ) { HorizontalMenuSelectUI instance = SpawnManager .SpawnCanvasElement(prefab.gameObject, 5) .GetComponentWithError <HorizontalMenuSelectUI>(); instance.cancelable = cancelable; instance.moveSound = moveSound; instance.selectSound = selectSound; instance.cancelSound = cancelSound; CreateMenuItems(models, instance); return(instance); }