void OnGUI()
    {
        if (toolbarSearchSkin == null)
        {
            toolbarSearchSkin = GUI.skin.FindStyle("ToolbarSeachTextField");
            if (toolbarSearchButtonSkin == null)
            {
                toolbarSearchButtonSkin = GUI.skin.FindStyle("ToolbarSeachCancelButton");
            }
        }
        EditorGUILayout.BeginVertical();
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);
        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Playground Wizard (C#)", EditorStyles.largeLabel, GUILayout.Height(20));
        EditorGUILayout.Separator();
        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.LabelField("Particle Playground v" + PlaygroundC.version.ToString());
        EditorGUILayout.Separator();

        // Create New-button
        if (GUILayout.Button("Create New Particle Playground System", EditorStyles.toolbarButton))
        {
            if (PlaygroundC.reference == null)
            {
                CreateManager();
            }
            PlaygroundParticlesC newParticlePlayground = PlaygroundC.Particle();
            Selection.activeGameObject = newParticlePlayground.particleSystemGameObject;
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndVertical();

        // Presets
        EditorGUILayout.BeginVertical("box");
        particlePresetFoldout = GUILayout.Toggle(particlePresetFoldout, "Presets", EditorStyles.foldout);
        if (particlePresetFoldout)
        {
            EditorGUILayout.BeginHorizontal("Toolbar");

            // Search
            string prevSearchString = searchString;
            searchString = GUILayout.TextField(searchString, toolbarSearchSkin, new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Width(Mathf.FloorToInt(Screen.width) - 170), GUILayout.MinWidth(170) });
            if (GUILayout.Button("", toolbarSearchButtonSkin))
            {
                searchString = "";
                GUI.FocusControl(null);
            }

            if (prevSearchString != searchString)
            {
                for (int p = 0; p < presetNames.Length; p++)
                {
                    presetObjects[p].unfiltered = (searchString == ""?true:presetNames[p].ToLower().Contains(searchString.ToLower()));
                }
            }

            EditorGUILayout.Separator();
            presetListStyle = GUILayout.Toolbar(presetListStyle, new string[] { "Icons", "List" }, EditorStyles.toolbarButton, GUILayout.MaxWidth(120));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginVertical("box");

            if (presetObjects.Count > 0)
            {
                int col1 = Mathf.FloorToInt(Screen.width / 2.2f) - 46;
                if (presetListStyle == 0)
                {
                    EditorGUILayout.BeginHorizontal();
                }
                int iconwidths = 0;
                for (int i = 0; i < presetObjects.Count; i++)
                {
                    // Filter out by search
                    if (!presetObjects[i].unfiltered)
                    {
                        continue;
                    }

                    // Preset Object were destroyed
                    if (!presetObjects[i].presetObject)
                    {
                        Initialize();
                        return;
                    }

                    // List
                    if (presetListStyle == 1)
                    {
                        EditorGUILayout.BeginVertical("box", GUILayout.MinHeight(22));
                        EditorGUILayout.BeginHorizontal();
                        presetObjects[i].foldout = GUILayout.Toggle(presetObjects[i].foldout, presetObjects[i].presetObject.name, EditorStyles.foldout);
                        EditorGUILayout.Separator();
                        if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50)))
                        {
                            CreatePresetObject(i);
                        }
                        EditorGUILayout.EndHorizontal();

                        if (presetObjects[i].foldout)
                        {
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Source:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));                       EditorGUILayout.LabelField(presetObjects[i].presetScript.source.ToString(), EditorStyles.miniLabel);                                    EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("States:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));                       EditorGUILayout.LabelField(presetObjects[i].presetScript.states.Count.ToString(), EditorStyles.miniLabel);                              EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Particle Count:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));       EditorGUILayout.LabelField(presetObjects[i].presetScript.particleCount.ToString(), EditorStyles.miniLabel);                             EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Emission Rate:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));        EditorGUILayout.LabelField(presetObjects[i].presetScript.emissionRate.ToString(), EditorStyles.miniLabel);                              EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Lifetime:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));                     EditorGUILayout.LabelField(presetObjects[i].presetScript.lifetime.ToString(), EditorStyles.miniLabel);                                  EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Sorting:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));                      EditorGUILayout.LabelField(presetObjects[i].presetScript.sorting.ToString(), EditorStyles.miniLabel);                                   EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Delta Movement:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));       EditorGUILayout.LabelField(presetObjects[i].presetScript.calculateDeltaMovement.ToString(), EditorStyles.miniLabel);    EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Lifetime Velocity:", EditorStyles.miniBoldLabel, GUILayout.Width(col1)); EditorGUILayout.LabelField(presetObjects[i].presetScript.applyLifetimeVelocity.ToString(), EditorStyles.miniLabel);         EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Initial Velocity:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));     EditorGUILayout.LabelField(presetObjects[i].presetScript.applyInitialVelocity.ToString(), EditorStyles.miniLabel);              EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Local Velocity:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));       EditorGUILayout.LabelField(presetObjects[i].presetScript.applyInitialLocalVelocity.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Velocity Bending:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));     EditorGUILayout.LabelField(presetObjects[i].presetScript.applyVelocityBending.ToString(), EditorStyles.miniLabel);              EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Collision:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));            EditorGUILayout.LabelField(presetObjects[i].presetScript.collision.ToString(), EditorStyles.miniLabel);                                 EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Material:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));                     EditorGUILayout.LabelField(presetObjects[i].presetScript.particleSystemRenderer.sharedMaterial.name.ToString(), EditorStyles.miniLabel); EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();      EditorGUILayout.LabelField("Update Rate:", EditorStyles.miniBoldLabel, GUILayout.Width(col1));          EditorGUILayout.LabelField(presetObjects[i].presetScript.updateRate.ToString(), EditorStyles.miniLabel);                                EditorGUILayout.EndHorizontal();

                            EditorGUILayout.Separator();
                            if (GUILayout.Button("Delete", EditorStyles.toolbarButton, GUILayout.Width(50)))
                            {
                                if (EditorUtility.DisplayDialog("Permanently delete this preset?",
                                                                "The preset " + presetObjects[i].presetObject.name + " will be removed, are you sure?",
                                                                "Yes",
                                                                "No"))
                                {
                                    AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(presetObjects[i].presetObject));
                                }
                            }
                        }

                        EditorGUILayout.EndVertical();
                    }


                    if (presetListStyle == 0)
                    {
                        // Break row for icons
                        iconwidths += 318;
                        if (iconwidths >= Screen.width && i > 0)
                        {
                            iconwidths = 318;
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                        }

                        if (Screen.width > 636)
                        {
                            EditorGUILayout.BeginVertical("box", GUILayout.Width(300));
                        }
                        else
                        {
                            EditorGUILayout.BeginVertical("box");
                        }
                        EditorGUILayout.BeginHorizontal(GUILayout.MinHeight(42));
                        if (GUILayout.Button(presetObjects[i].presetImage, new GUILayoutOption[] { GUILayout.Width(44), GUILayout.Height(40) }))
                        {
                            CreatePresetObject(i);
                        }
                        EditorGUILayout.BeginVertical();
                        if (GUILayout.Button(presetObjects[i].presetScript.name.ToString(), EditorStyles.label, new GUILayoutOption[] { GUILayout.Height(18) }))
                        {
                            CreatePresetObject(i);
                        }
                        EditorGUILayout.LabelField(presetObjects[i].presetScript.source.ToString() + " (" + presetObjects[i].presetScript.particleCount.ToString() + ")", EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.Height(18), GUILayout.Width(240) });
                        EditorGUILayout.EndVertical();
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.EndVertical();
                    }
                }
                if (presetListStyle == 0)
                {
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No presets found. Make sure that the path to the presets are set to: \"" + playgroundPath + presetPath + "\"", MessageType.Info);
            }

            if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50)))
            {
                PlaygroundCreatePresetWindowC.ShowWindow();
            }

            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndVertical();

        PlaygroundInspectorC.RenderPlaygroundSettings();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Official Site", EditorStyles.toolbarButton))
        {
            Application.OpenURL("http://playground.polyfied.com/");
        }
        if (GUILayout.Button("Asset Store", EditorStyles.toolbarButton))
        {
            Application.OpenURL("http://u3d.as/5ZJ");
        }
        if (GUILayout.Button("Support Forum", EditorStyles.toolbarButton))
        {
            Application.OpenURL("http://forum.unity3d.com/threads/215154-Particle-Playground");
        }
        if (GUILayout.Button("Mail Support", EditorStyles.toolbarButton))
        {
            Application.OpenURL("mailto:[email protected]");
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        GUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
Пример #2
0
    void OnGUI()
    {
        if (toolbarSearchSkin == null)
        {
            toolbarSearchSkin = GUI.skin.FindStyle("ToolbarSeachTextField");
            if (toolbarSearchButtonSkin == null)
            {
                toolbarSearchButtonSkin = GUI.skin.FindStyle("ToolbarSeachCancelButton");
            }
        }
        EditorGUILayout.BeginVertical();
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);
        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Particle Playground " + PlaygroundC.version + PlaygroundC.specialVersion, EditorStyles.largeLabel, GUILayout.Height(20));
        EditorGUILayout.Separator();

        // New version message
        if (!didSendVersionCheck)
        {
            CheckUpdate();
        }
        if (updateAvailable)
        {
            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Update available");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("x", EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(18) }))
            {
                updateAvailable = false;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.LabelField("Update " + onlineVersion + " is available. Please visit the Unity Asset Store to download the new version.", EditorStyles.wordWrappedMiniLabel);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Unity Asset Store", EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                Application.OpenURL("http://u3d.as/5ZJ");
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            EditorGUILayout.Separator();
        }
        EditorGUILayout.BeginVertical("box");

        // Create New-buttons
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Particle Playground System", EditorStyles.toolbarButton))
        {
            if (PlaygroundC.reference == null)
            {
                CreateManager();
            }
            PlaygroundParticlesC newParticlePlayground = PlaygroundC.Particle();
            Selection.activeGameObject = newParticlePlayground.particleSystemGameObject;
        }
        GUI.enabled = PlaygroundC.reference == null;
        if (GUILayout.Button("Playground Manager", EditorStyles.toolbarButton))
        {
            PlaygroundC.ResourceInstantiate("Playground Manager");
        }
        GUI.enabled = true;
        if (GUILayout.Button("Preset Wizard", EditorStyles.toolbarButton))
        {
            PlaygroundCreatePresetWindowC.ShowWindow();
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndVertical();

        // Presets
        EditorGUILayout.BeginVertical("box");
        particlePresetFoldout = GUILayout.Toggle(particlePresetFoldout, "Presets", EditorStyles.foldout);
        if (particlePresetFoldout)
        {
            EditorGUILayout.BeginHorizontal("Toolbar");

            // Search
            string prevSearchString = searchString;
            searchString = GUILayout.TextField(searchString, toolbarSearchSkin, new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Width(Mathf.FloorToInt(Screen.width) - 120), GUILayout.MinWidth(100) });
            if (GUILayout.Button("", toolbarSearchButtonSkin))
            {
                searchString = "";
                GUI.FocusControl(null);
            }

            if (prevSearchString != searchString)
            {
                for (int p = 0; p < presetNames.Length; p++)
                {
                    presetObjects[p].unfiltered = (searchString == ""?true:presetNames[p].ToLower().Contains(searchString.ToLower()));
                }
            }

            EditorGUILayout.Separator();
            presetExampleUser = GUILayout.Toolbar(presetExampleUser, new string[] { "All", "User", "Examples" }, EditorStyles.toolbarButton, GUILayout.MaxWidth(170));
            GUILayout.Label("", EditorStyles.toolbarButton);
            presetListStyle = GUILayout.Toolbar(presetListStyle, new string[] { "Icons", "List" }, EditorStyles.toolbarButton, GUILayout.MaxWidth(120));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginVertical("box");

            if (presetObjects.Count > 0)
            {
                if (presetListStyle == 0)
                {
                    EditorGUILayout.BeginHorizontal();
                }
                int rows           = 1;
                int iconwidths     = 0;
                int skippedPresets = 0;
                for (int i = 0; i < presetObjects.Count; i++)
                {
                    // Filter out by search
                    if (!presetObjects[i].unfiltered || presetExampleUser == 2 && !presetObjects[i].example || presetExampleUser == 1 && presetObjects[i].example)
                    {
                        skippedPresets++;
                        continue;
                    }
                    // Preset Object were destroyed
                    if (presetObjects[i].presetObject == null)
                    {
                        Initialize();
                        return;
                    }

                    // List
                    if (presetListStyle == 1)
                    {
                        EditorGUILayout.BeginVertical("box", GUILayout.MinHeight(24));
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(i.ToString(), EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.Width(18) });
                        EditorGUILayout.LabelField(presetObjects[i].example?"(Example)":"(User)", EditorStyles.miniLabel, new GUILayoutOption[] { GUILayout.Width(50) });
                        if (GUILayout.Button(presetObjects[i].presetObject.name, EditorStyles.label))
                        {
                            CreatePresetObject(i);
                        }
                        EditorGUILayout.Separator();
                        if (GUILayout.Button(presetObjects[i].example?"Convert to User":"******", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(106), GUILayout.Height(16) }))
                        {
                            if (presetObjects[i].example)
                            {
                                AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(presetObjects[i].presetObject), "Assets/" + playgroundPath + presetPath + presetObjects[i].presetObject.name + ".prefab");
                            }
                            else
                            {
                                AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(presetObjects[i].presetObject), "Assets/" + playgroundPath + examplePresetPath + presetObjects[i].presetObject.name + ".prefab");
                            }
                        }
                        if (GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) }))
                        {
                            RemovePreset(presetObjects[i].presetObject);
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.EndVertical();
                    }


                    if (presetListStyle == 0)
                    {
                        // Break row for icons
                        rows        = Mathf.FloorToInt(Screen.width / 322);
                        iconwidths += 322;
                        if (iconwidths > Screen.width && i > 0)
                        {
                            iconwidths = 322;
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                        }

                        if (Screen.width >= 644)
                        {
                            EditorGUILayout.BeginVertical("box", GUILayout.MaxWidth(Mathf.CeilToInt(Screen.width / rows) - (44 / rows)));
                        }
                        else
                        {
                            EditorGUILayout.BeginVertical("box");
                        }
                        EditorGUILayout.BeginHorizontal(GUILayout.MinHeight(46));
                        if (GUILayout.Button(presetObjects[i].presetImage, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(44), GUILayout.Height(44) }))
                        {
                            CreatePresetObject(i);
                        }
                        EditorGUILayout.BeginVertical();

                        if (GUILayout.Button(presetObjects[i].presetObject.name, EditorStyles.label, GUILayout.Height(18)))
                        {
                            CreatePresetObject(i);
                        }
                        EditorGUILayout.LabelField(presetObjects[i].example?"Example":"User", EditorStyles.miniLabel);
                        EditorGUILayout.EndVertical();
                        GUILayout.FlexibleSpace();
                        EditorGUILayout.BeginVertical();

                        if (GUILayout.Button("x", EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(18) }))
                        {
                            RemovePreset(presetObjects[i].presetObject);
                        }
                        EditorGUILayout.EndVertical();
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.EndVertical();
                    }
                }
                if (skippedPresets == presetObjects.Count)
                {
                    if (searchString != "")
                    {
                        EditorGUILayout.HelpBox("No preset found containing \"" + searchString + "\".", MessageType.Info);
                    }
                    else
                    {
                        if (presetExampleUser == 0)
                        {
                            EditorGUILayout.HelpBox("No presets found. Press \"Create\" to make a new preset.", MessageType.Info);
                        }
                        else if (presetExampleUser == 1)
                        {
                            EditorGUILayout.HelpBox("No user presets found in any \"Resources/Presets\" folder. Press \"Create\" to make a new preset.", MessageType.Info);
                        }
                        else if (presetExampleUser == 2)
                        {
                            EditorGUILayout.HelpBox("No example presets found. Make sure they are stored in \"" + "Assets/" + playgroundPath + examplePresetPath + "\"", MessageType.Info);
                        }
                    }
                }
                if (presetListStyle == 0)
                {
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No presets found. Make sure that the path to the presets are set to: \"" + "Assets/" + playgroundPath + examplePresetPath + "\"", MessageType.Info);
            }

            if (GUILayout.Button("Create", EditorStyles.toolbarButton, GUILayout.Width(50)))
            {
                PlaygroundCreatePresetWindowC.ShowWindow();
            }

            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndVertical();

        PlaygroundInspectorC.RenderPlaygroundSettings();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Official Site", EditorStyles.toolbarButton))
        {
            Application.OpenURL("http://playground.polyfied.com/");
        }
        if (GUILayout.Button("Asset Store", EditorStyles.toolbarButton))
        {
            Application.OpenURL("http://u3d.as/5ZJ");
        }
        if (GUILayout.Button("Manual", EditorStyles.toolbarButton))
        {
            Application.OpenURL("http://www.polyfied.com/products/Particle-Playground-2-Next-Manual.pdf");
        }
        if (GUILayout.Button("Support Forum", EditorStyles.toolbarButton))
        {
            Application.OpenURL("http://forum.unity3d.com/threads/215154-Particle-Playground");
        }
        if (GUILayout.Button("Mail Support", EditorStyles.toolbarButton))
        {
            Application.OpenURL("mailto:[email protected]");
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        GUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
    void OnGUI()
    {
        if (window == null)
        {
            this.Close();
            return;
        }

        EditorGUILayout.BeginVertical();

        scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField(playgroundLanguage.presetManager, EditorStyles.largeLabel, GUILayout.Height(20));
        EditorGUILayout.Separator();

        GUILayout.BeginVertical("box");
        EditorGUILayout.HelpBox(playgroundLanguage.categoriesInfo, MessageType.Info);
        EditorGUILayout.Separator();

        for (int i = 0; i < PlaygroundParticleWindowC.presetCategories.Count; i++)
        {
            GUILayout.BeginVertical("box");

            GUILayout.BeginHorizontal();

            PresetCategory thisCategory = PlaygroundParticleWindowC.presetCategories[i];

            bool isProtectedFolder = thisCategory.categoryName == "Uncategorized" || thisCategory.categoryName == "Resources";

            // Category unfold
            thisCategory.foldout = GUILayout.Toggle(thisCategory.foldout, "", EditorStyles.foldout, GUILayout.MaxWidth(16f));

            // Category name
            GUI.enabled = !isProtectedFolder;
            GUI.SetNextControlName(thisCategory.categoryName);
            thisCategory.tmpNewName = EditorGUILayout.TextField(thisCategory.tmpNewName, EditorStyles.toolbarTextField);
            GUI.enabled             = true;
            if (!isProtectedFolder && thisCategory.tmpNewName != thisCategory.categoryName)
            {
                if (GUILayout.Button(playgroundLanguage.rename, GUILayout.ExpandWidth(false)))
                {
                    bool isValidFolderName = IsValidFolderName(thisCategory.tmpNewName);
                    if (isValidFolderName)
                    {
                        if (AssetDatabase.RenameAsset("Assets/" + thisCategory.categoryLocation, thisCategory.tmpNewName).Length == 0)
                        {
                            AssetDatabase.Refresh();

                            // Succesfully renamed
                            thisCategory.categoryName = thisCategory.tmpNewName;
                            requestFocusControl       = true;
                            focusControlName          = thisCategory.categoryName;
                            return;
                        }
                        else
                        {
                            thisCategory.tmpNewName = thisCategory.categoryName;
                        }
                    }
                    else
                    {
                        thisCategory.tmpNewName = thisCategory.categoryName;
                    }
                }
            }

            // Show amount of selected presets
            int selectedPresetsInCategory = 0;
            for (int x = 0; x < thisCategory.presetObjects.Count; x++)
            {
                if (thisCategory.presetObjects[x].selected)
                {
                    selectedPresetsInCategory++;
                }
            }
            GUI.enabled = selectedPresetsInCategory > 0;
            GUILayout.Label("(" + selectedPresetsInCategory.ToString() + "/" + thisCategory.presetObjects.Count.ToString() + ")");
            GUI.enabled = true;

            EditorGUILayout.Separator();

            // Remove category
            GUI.enabled = !isProtectedFolder;
            if (GUILayout.Button("-", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(18), GUILayout.Height(16) }) && !isProtectedFolder)
            {
                if (EditorUtility.DisplayDialog(playgroundLanguage.removeCategory,
                                                thisCategory.categoryName + " " + playgroundLanguage.removeCategoryText,
                                                playgroundLanguage.yes,
                                                playgroundLanguage.no))
                {
                    // Move all presets contained to "Uncategorized" (parent folder) before removing the category folder
                    string[] presetsInCategory = Directory.GetFiles(Application.dataPath + "/" + thisCategory.categoryLocation);
                    foreach (string presetLoc in presetsInCategory)
                    {
                        string convertedPresetPath = presetLoc.Substring(Application.dataPath.Length - 6);
                        Object presetPathObject    = (Object)AssetDatabase.LoadAssetAtPath(convertedPresetPath, typeof(Object));
                        if (presetPathObject != null && (presetPathObject.GetType().Name) == "GameObject")
                        {
                            AssetDatabase.MoveAsset(convertedPresetPath, "Assets/" + playgroundSettings.playgroundPath + playgroundSettings.examplePresetPath + presetPathObject.name);
                        }
                    }
                    AssetDatabase.MoveAssetToTrash("Assets/" + thisCategory.categoryLocation);
                    AssetDatabase.Refresh();
                    GUI.FocusControl(null);
                    return;
                }
            }
            GUI.enabled = true;

            GUILayout.EndHorizontal();

            // List of presets
            if (thisCategory.foldout)
            {
                EditorGUILayout.Separator();

                // Mixed selection
                if (thisCategory.presetObjects.Count > 0)
                {
                    EditorGUI.showMixedValue = selectedPresetsInCategory > 0 && selectedPresetsInCategory < thisCategory.presetObjects.Count;
                    bool multiSelect = selectedPresetsInCategory > 0;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(4f);
                    multiSelect = EditorGUILayout.Toggle(multiSelect);
                    EditorGUILayout.EndHorizontal();
                    if (EditorGUI.EndChangeCheck())
                    {
                        for (int x = 0; x < thisCategory.presetObjects.Count; x++)
                        {
                            thisCategory.presetObjects[x].selected = multiSelect;
                        }
                    }
                    EditorGUI.showMixedValue = false;
                }

                EditorGUI.indentLevel++;

                if (thisCategory.presetObjects.Count > 0)
                {
                    for (int x = 0; x < thisCategory.presetObjects.Count; x++)
                    {
                        GUILayout.BeginHorizontal("box");
                        PresetObjectC thisPreset = thisCategory.presetObjects[x];
                        thisPreset.selected = GUILayout.Toggle(thisPreset.selected, "", GUILayout.MaxWidth(24f));
                        if (GUILayout.Button(thisPreset.presetImage, EditorStyles.label, new GUILayoutOption[] { GUILayout.Width(24), GUILayout.Height(24) }) ||
                            GUILayout.Button(thisPreset.presetObject.name, EditorStyles.label))
                        {
                            EditorGUIUtility.PingObject(thisPreset.presetObject);
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                else
                {
                    GUI.enabled = false;
                    GUILayout.Label(playgroundLanguage.empty);
                    GUI.enabled = true;
                }
                EditorGUI.indentLevel--;
            }

            GUILayout.EndVertical();
        }

        // New category creation
        EditorGUILayout.Separator();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(playgroundLanguage.create, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
        {
            if (IsValidFolderName(createCategoryName))
            {
                createCategoryName = createCategoryName.Trim();
                string createdFolder = AssetDatabase.CreateFolder("Assets/" + playgroundSettings.playgroundPath + (playgroundSettings.examplePresetPath).Substring(0, playgroundSettings.examplePresetPath.Length - 1), createCategoryName);
                if (createdFolder != null && createdFolder.Length > 0)
                {
                    AssetDatabase.Refresh();
                    foreach (PresetCategory cat in PlaygroundParticleWindowC.presetCategories)
                    {
                        if (AssetDatabase.AssetPathToGUID("Assets/" + cat.categoryLocation) == createdFolder)
                        {
                            cat.foldout         = true;
                            requestFocusControl = true;
                            focusControlName    = cat.categoryName;
                            break;
                        }
                    }
                    createCategoryName = "New Category";
                    return;
                }
            }
        }
        createCategoryName = EditorGUILayout.TextField(createCategoryName, EditorStyles.toolbarTextField);
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();

        GUILayout.EndScrollView();

        int  selectedPresets        = 0;
        bool isResourcesPresetsOnly = true;

        for (int i = 0; i < PlaygroundParticleWindowC.presetCategories.Count; i++)
        {
            for (int x = 0; x < PlaygroundParticleWindowC.presetCategories[i].presetObjects.Count; x++)
            {
                if (PlaygroundParticleWindowC.presetCategories[i].presetObjects[x].selected)
                {
                    if (PlaygroundParticleWindowC.presetCategories[i].presetObjects[x].example)
                    {
                        isResourcesPresetsOnly = false;
                    }
                    selectedPresets++;
                }
            }
        }

        // Bottom toolbar for selected presets
        if (selectedPresets > 0)
        {
            EditorGUILayout.BeginHorizontal("box");
            EditorGUILayout.LabelField(playgroundLanguage.selected + ": " + selectedPresets.ToString(), GUILayout.MaxWidth(90));

            // Move selected presets
            if (categoryNames == null || categoryNames.Length != PlaygroundParticleWindowC.presetCategories.Count + 1)
            {
                categoryNames    = new string[PlaygroundParticleWindowC.presetCategories.Count + 1];
                categoryNames[0] = playgroundLanguage.move + "...";
                for (int i = 0; i < PlaygroundParticleWindowC.presetCategories.Count; i++)
                {
                    categoryNames[i + 1] = PlaygroundParticleWindowC.presetCategories[i].categoryName;
                }
            }
            int selectedMoveCategory = 0;
            EditorGUI.BeginChangeCheck();
            selectedMoveCategory = EditorGUILayout.Popup(selectedMoveCategory, categoryNames, EditorStyles.toolbarPopup);
            if (EditorGUI.EndChangeCheck())
            {
                if (selectedMoveCategory > 0)
                {
                    List <Object> movedObjects = new List <Object>();
                    foreach (PresetCategory cat in PlaygroundParticleWindowC.presetCategories)
                    {
                        foreach (PresetObjectC obj in cat.presetObjects)
                        {
                            if (obj.selected)
                            {
                                movedObjects.Add(obj.presetObject);
                                AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(obj.presetObject), "Assets/" + PlaygroundParticleWindowC.presetCategories[selectedMoveCategory - 1].categoryLocation + "/" + obj.presetObject.name);
                            }
                        }
                    }
                    AssetDatabase.Refresh();

                    // Select the moved objects once again for less confusion
                    foreach (PresetCategory cat in PlaygroundParticleWindowC.presetCategories)
                    {
                        foreach (PresetObjectC obj in cat.presetObjects)
                        {
                            if (movedObjects.Contains(obj.presetObject))
                            {
                                obj.selected = true;
                            }
                        }
                    }

                    // Open the index, correct if 'Uncategorized' got removed in the process
                    int openIndex = selectedMoveCategory - 1 < PlaygroundParticleWindowC.presetCategories.Count? selectedMoveCategory - 1 : selectedMoveCategory - 2;
                    PlaygroundParticleWindowC.presetCategories[openIndex].foldout = true;
                }
            }

            GUILayout.Space(4f);

            // Convert selected presets to Resources
            GUI.enabled = !isResourcesPresetsOnly;
            if (GUILayout.Button(playgroundLanguage.convertTo + " " + playgroundLanguage.resources, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                if (EditorUtility.DisplayDialog(playgroundLanguage.convertPresetsIntoResources,
                                                playgroundLanguage.convertPresetsIntoResourcesText,
                                                playgroundLanguage.yes,
                                                playgroundLanguage.no))
                {
                    List <Object> convertedObjects = new List <Object>();

                    foreach (PresetCategory cat in PlaygroundParticleWindowC.presetCategories)
                    {
                        foreach (PresetObjectC obj in cat.presetObjects)
                        {
                            if (obj.selected)
                            {
                                if (!Directory.Exists(Application.dataPath + "/" + playgroundSettings.playgroundPath + playgroundSettings.presetPath))
                                {
                                    Directory.CreateDirectory(Application.dataPath + "/" + playgroundSettings.playgroundPath + playgroundSettings.presetPath);
                                    AssetDatabase.Refresh();
                                }
                                convertedObjects.Add(obj.presetObject);
                                AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(obj.presetObject), "Assets/" + playgroundSettings.playgroundPath + playgroundSettings.presetPath + obj.presetObject.name);
                            }
                        }
                    }

                    // Select the converted objects once again for less confusion
                    foreach (PresetCategory cat in PlaygroundParticleWindowC.presetCategories)
                    {
                        foreach (PresetObjectC obj in cat.presetObjects)
                        {
                            if (convertedObjects.Contains(obj.presetObject))
                            {
                                obj.selected = true;
                            }
                        }
                    }

                    PlaygroundParticleWindowC.presetCategories[PlaygroundParticleWindowC.presetCategories.Count - 1].foldout = true;
                }
            }
            GUI.enabled = true;

            GUILayout.Space(4f);

            // Remove selected presets
            if (GUILayout.Button(playgroundLanguage.remove, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                if (EditorUtility.DisplayDialog(playgroundLanguage.removeSelectedPresets,
                                                playgroundLanguage.removeSelectedPresetsText,
                                                playgroundLanguage.yes,
                                                playgroundLanguage.no))
                {
                    foreach (PresetCategory cat in PlaygroundParticleWindowC.presetCategories)
                    {
                        foreach (PresetObjectC obj in cat.presetObjects)
                        {
                            if (obj.selected)
                            {
                                AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(obj.presetObject));
                            }
                        }
                    }
                }
            }

            GUILayout.Space(4f);

            // Publish selected presets
            if (GUILayout.Button(playgroundLanguage.publish, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                PlaygroundCreatePresetWindowC.ShowWindowPublish();
            }

            EditorGUILayout.Separator();

            // Deselect selected presets
            if (GUILayout.Button(playgroundLanguage.deselectAll, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                for (int i = 0; i < PlaygroundParticleWindowC.presetCategories.Count; i++)
                {
                    for (int x = 0; x < PlaygroundParticleWindowC.presetCategories[i].presetObjects.Count; x++)
                    {
                        PlaygroundParticleWindowC.presetCategories[i].presetObjects[x].selected = false;
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.EndVertical();

        if (requestFocusControl)
        {
            EditorGUI.FocusTextInControl(focusControlName);
            requestFocusControl = false;
        }
    }