public void Setup() { Util.FindIfNotSet(this, ref editMain); Util.FindIfNotSet(this, ref userMain); Util.FindIfNotSet(this, ref assetSearch); Util.FindIfNotSet(this, ref sceneActorLibrary); renderableLibraryUI.searchInput.onEndEdit.AddListener(OnInputFieldEnd); renderableLibraryUI.clearSearchButton.onClick.AddListener(ClearSearch); assetSearch.AddPrefabsProcessor((searchResult) => OnResult(searchResult, true)); List <Util.Tuple <string, Texture2D> > allCategories = new List <Util.Tuple <string, Texture2D> >(); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_ALL, allCategoryIcon)); foreach (CategoryButton category in dynamicCategories) { allCategories.Add(new Util.Tuple <string, Texture2D>(category.displayName, category.icon)); } allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_DECORATIONS, decorationCategoryIcon)); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_POLY, polyCategoryIcon)); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_GIS, gisCategoryIcon)); // allCategories.Add(new Util.Tuple<string, Texture2D>(CATEGORY_CHALLENGE, challengeCategoryIcon)); foreach (Util.Tuple <string, Texture2D> categoryTuple in allCategories) { string category = categoryTuple.first; Texture2D texture = categoryTuple.second; TextIconButtonUI categoryButton = Instantiate( renderableLibraryUI.categoryButtonPrefab, renderableLibraryUI.categoriesList.transform); categoryButton.text.text = category; categoryButton.icon.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0)); categoryButton.button.onClick.AddListener(() => { selectedCategory = category; UpdateAll(); }); // if (category == CATEGORY_CHALLENGE) // { // categoryButton.medallion.gameObject.SetActive(true); // } categoryButton.gameObject.SetActive(true); } renderableLibraryUI.inCategoryBackButton.onClick.AddListener(() => { selectedCategory = null; UpdateAll(); }); renderableLibraryUI.inCategoryLink.onClick.AddListener(() => { Application.OpenURL(challengeCategoryUrl); }); renderableLibraryUI.closeButton.onClick.AddListener(() => { gameObject.SetActive(false); }); }
public override void Setup(SidebarManager _sidebarManager) { base.Setup(_sidebarManager); Util.FindIfNotSet(this, ref editMain); Util.FindIfNotSet(this, ref userMain); Util.FindIfNotSet(this, ref assetSearch); Util.FindIfNotSet(this, ref sceneActorLibrary); Util.FindIfNotSet(this, ref popups); ShouldShowInternalResult = (result) => { return(false); }; lastResult = assetSearch.GetBuiltInSearchResult("Forest/Slime"); creationLibraryUI.searchInput.onEndEdit.AddListener(OnInputFieldEnd); creationLibraryUI.clearSearchButton.onClick.AddListener(ClearSearch); sceneActorLibrary.onActorPut += OnActorPut; sceneActorLibrary.onActorDelete += OnActorDelete; assetSearch.AddPrefabsProcessor((searchResult) => OnResult(searchResult, true)); List <Util.Tuple <string, Texture2D> > allCategories = new List <Util.Tuple <string, Texture2D> >(); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_ALL, allCategoryIcon)); foreach (CategoryButton category in dynamicCategories) { allCategories.Add(new Util.Tuple <string, Texture2D>(category.displayName, category.icon)); } allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_DECORATIONS, decorationCategoryIcon)); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_CUSTOM, savedCategoryIcon)); //NO_POLY_TOOLKIT_INTERNAL_CHECK if (!PolyToolkitInternal.PtSettings.Instance.authConfig.apiKey.Contains("INSERT YOUR")) { allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_POLY, polyCategoryIcon)); } if (GisSearchManager.APIkey != "PUT YOUR KEY HERE") { allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_GIS, gisCategoryIcon)); } allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_PARTICLES, particlesCategoryIcon)); allCategories.Add(new Util.Tuple <string, Texture2D>(CATEGORY_SOUNDS, soundsCategoryIcon)); foreach (Util.Tuple <string, Texture2D> categoryTuple in allCategories) { string category = categoryTuple.first; Texture2D texture = categoryTuple.second; TextIconButtonUI categoryButton = Instantiate( creationLibraryUI.categoryButtonPrefab, creationLibraryUI.categoriesList.transform); categoryButton.text.text = category; categoryButton.icon.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0)); categoryButton.button.onClick.AddListener(() => { selectedCategory = category; UpdateAll(); }); if (category == CATEGORY_CHALLENGE) { categoryButton.medallion.gameObject.SetActive(true); } categoryButton.gameObject.SetActive(true); } creationLibraryUI.inCategoryBackButton.onClick.AddListener(() => { selectedCategory = null; ClearSearch(); //includes update all // UpdateAll(); }); particleLibrary.Setup(); particleLibrary.onParticleEffectSelected += OnParticleEffectSelected; soundLibrary.onSoundSelected += OnSoundEffectSelected; soundLibrary.Setup(); creationLibraryUI.inCategoryLink.onClick.AddListener(() => { Application.OpenURL(challengeCategoryUrl); }); #if USE_STEAMWORKS actorPrefabUploadDialog = Instantiate(actorPrefabUploadDialogPrefab); actorPrefabUploadDialog.Setup(); actorPrefabWorkshopMenu = Instantiate(actorPrefabWorkshopMenuPrefab); actorPrefabWorkshopMenu.Setup(); #endif creationLibraryUI.exportDropdownMenu.onOptionClicked += (value) => { SquareImageButtonUI exportResult = selectedResult; Debug.Assert(selectedResult != null); ActorPrefab prefab = exportResult.GetSearchResult().actorPrefab; Debug.Assert(sceneActorLibrary.Exists(prefab?.GetId())); if (value == EXPORT_TO_DISK) { ExportToDisk(prefab); } #if USE_STEAMWORKS else if (value == UPDATE_WORKSHOP_PREFAB) { ulong?id = GetWorkshopIdForActor(prefab); actorPrefabUploadDialog.Open(prefab, Util.Maybe <ulong> .CreateWith(id.Value)); } else { actorPrefabUploadDialog.Open(prefab, Util.Maybe <ulong> .CreateEmpty()); } #endif }; #if USE_STEAMWORKS creationLibraryUI.importDropdownMenu.SetOptions(new List <string>() { IMPORT_FROM_DISK, IMPORT_FROM_WORKSHOP }); #else creationLibraryUI.importCustomButton.onClick.AddListener(ImportFromDisk); #endif creationLibraryUI.importDropdownMenu.onOptionClicked += (value) => { if (value == IMPORT_FROM_DISK) { ImportFromDisk(); } else { actorPrefabWorkshopMenu.Open(); } }; pfxActorTemplate = assetSearch.GetBuiltInSearchResult("Empty"); sfxActorTemplate = assetSearch.GetBuiltInSearchResult("Sound"); }