public virtual GameObject CreateListEntryUi(ActionMenu menu, bool showOnlyFavs, TaskCompletionSource <Entry> taskComplSource) { var entry = this; var listEntryUiGo = ResourcesV2.LoadPrefab(entry.listModeEntryPrefabName); var map = listEntryUiGo.GetLinkMap(); map.Get <Text>("Icon").text = entry.icon; map.Get <Text>("Title").text = entry.name; var description = map.Get <Text>("Description"); description.gameObject.SetActiveV2(menu.viewMode == ViewMode.full && !entry.descr.IsNullOrEmpty()); description.text = entry.descr; var button = map.Get <Button>("ActionSelected"); button.interactable = entry.isEnabled; map.Get <CanvasGroup>("ActionSelected").enabled = !entry.isEnabled; button.SetOnClickAction(go => { if (menu.entries.Contains(entry)) { menu.clickedEntry = entry; EventBus.instance.Publish(EventConsts.catUi + UiEvents.ACTION_MENU, menu.GetFullEntryId(entry)); taskComplSource.TrySetResult(entry); } entry.onClicked.InvokeIfNotNull(go); }); var onFavorite = map.Get <Toggle>("FavoriteToggle"); onFavorite.gameObject.SetActiveV2(!showOnlyFavs && entry.onFavoriteToggled != null); onFavorite.isOn = entry.isFavorite; onFavorite.SetOnValueChangedAction(entry.onFavoriteToggled); return(listEntryUiGo); }
public virtual GameObject CreateIconEntryUi(ActionMenu menu, TaskCompletionSource <Entry> taskComplSource) { var entry = this; var iconGo = ResourcesV2.LoadPrefab(entry.iconModeEntryPrefabName); iconGo.GetComponentInChildren <Text>().text = entry.icon; var button = iconGo.GetComponentInChildren <Button>(); button.interactable = entry.isEnabled; iconGo.GetComponentInChildren <CanvasGroup>().enabled = !entry.isEnabled; button.SetOnClickAction(btnGo => { if (menu.entries.Contains(entry)) { menu.clickedEntry = entry; EventBus.instance.Publish(EventConsts.catUi + UiEvents.ACTION_MENU, menu.GetFullEntryId(entry)); taskComplSource.TrySetResult(entry); } entry.onClicked.InvokeIfNotNull(btnGo); }); return(iconGo); }