private void OnEnable() { ObjectSelection.CategoryChanged += CategoryChanged; ObjectSelection.ClearList(); PopulateList(); }
private void PopulateList() { ObjectSelection.ClearList(); var spawnablesByType = SpawnableManager.Prefabs.Where(x => x.Type == (Enumerations.SpawnableType)ObjectSelection.CurrentCategoryIndex).ToList(); if (spawnablesByType.Any()) { foreach (var spawnable in spawnablesByType) { string displayText = string.IsNullOrEmpty(spawnable.MenuText) ? spawnable.Prefab.name.Replace("selectable", string.Empty) : spawnable.MenuText; ObjectSelection.AddToList(displayText, spawnable.PreviewTexture, () => ObjectClicked(spawnable), () => ListItemSelected(spawnable)); } if (ObjectSelection.ListContent.transform.childCount > 0) { EventSystem.current.SetSelectedGameObject(ObjectSelection.ListContent.transform.GetChild(0).gameObject); } } }
private void OnDisable() { ObjectSelection.ClearList(); ObjectSelection.CategoryChanged -= CategoryChanged; }