Exemplo n.º 1
0
    public void ResetAsset()
    {
        ActorableSearchResult newResult = assetSearch.GetBuiltInSearchResult(defaultAssets[currentIndex]);

        UpdateAssetAtIndex(newResult, currentIndex);
    }
Exemplo n.º 2
0
    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");
    }