コード例 #1
0
        public override void OnInspectorGUI()
        {
            PoolManager t = (PoolManager)target;

            EditorGUILayout.Space();

            t.dontDestroyOnLoad = EditorTools.Toggle("Don't destroy on load", t.dontDestroyOnLoad, true);
            EditorGUILayout.Space();

            t.isGarbageCollector = EditorTools.Toggle("Enable garbage collector", t.isGarbageCollector);
            if (t.isGarbageCollector)
            {
                t.garbageCycletime = EditorGUILayout.FloatField("Garbage cycle time", t.garbageCycletime);
            }


            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            EditorTools.Title("Per-Object Pool options", false, Screen.width - 55);
            if (EditorTools.ButtonTitle("+", false, 22))
            {
                PoolProperty po = new PoolProperty();
                t.poolObjectsProperties.Add(po);
            }
            EditorGUILayout.EndHorizontal();


            if (t.poolObjectsProperties.Count > 0)
            {
                EditorTools.BeginGroup(); {
                    EditorGUILayout.Space();
                    for (int i = 0; i < t.poolObjectsProperties.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        if (EditorTools.Button("X", Color.red, 19))
                        {
                            PoolManager.DestroyPool(t.poolObjectsProperties[i].obj, true);
                            t.poolObjectsProperties.RemoveAt(i);
                            i--;
                        }
                        if (i >= 0)
                        {
                            string label = "Empty";
                            if (t.poolObjectsProperties[i].obj)
                            {
                                label = t.poolObjectsProperties[i].obj.name;
                            }
                            t.poolObjectsProperties[i].showInpsector = EditorTools.ChildFoldOut(t.poolObjectsProperties[i].showInpsector, label, Color.white, Screen.width - 60);
                        }
                        EditorGUILayout.EndHorizontal();

                        if (i >= 0)
                        {
                            if (t.poolObjectsProperties[i].showInpsector)
                            {
                                EditorTools.BeginGroup(25); {
                                    EditorGUI.indentLevel++;

                                    // Prefab
                                    GameObject tmpObj = (GameObject)EditorGUILayout.ObjectField("Prefab", t.poolObjectsProperties[i].obj, typeof(GameObject), true);
                                    if (tmpObj != t.poolObjectsProperties[i].obj)
                                    {
                                        PoolManager.DestroyPool(t.poolObjectsProperties[i].obj, true);

                                        t.poolObjectsProperties[i].obj = tmpObj;

                                        //if (!t.poolObjectsProperties[i].preLoadAtStart){
                                        PoolManager.CreatePool(t.poolObjectsProperties[i].obj, t.poolObjectsProperties[i].poolAmount);
                                        //}
                                    }

                                    EditorGUILayout.Space();

                                    // Preload
                                    bool tmpBool = EditorTools.Toggle("Pre-Load at start", t.poolObjectsProperties[i].preLoadAtStart);
                                    if (tmpBool != t.poolObjectsProperties[i].preLoadAtStart)
                                    {
                                        t.poolObjectsProperties[i].preLoadAtStart = tmpBool;
                                        if (t.poolObjectsProperties[i].preLoadAtStart)
                                        {
                                            PoolManager.DestroyPool(t.poolObjectsProperties[i].obj, true);
                                        }
                                        else
                                        {
                                            PoolManager.DestroyPool(t.poolObjectsProperties[i].obj, true);
                                            PoolManager.CreatePool(t.poolObjectsProperties[i].obj, t.poolObjectsProperties[i].poolAmount);
                                        }
                                    }

                                    int amount = EditorGUILayout.IntField("Preload Amount", t.poolObjectsProperties[i].poolAmount);
                                    if (amount != t.poolObjectsProperties[i].poolAmount)
                                    {
                                        t.poolObjectsProperties[i].poolAmount = amount;
                                        PoolManager.DestroyPool(t.poolObjectsProperties[i].obj, true);
                                        if (!t.poolObjectsProperties[i].preLoadAtStart)
                                        {
                                            PoolManager.CreatePool(t.poolObjectsProperties[i].obj, t.poolObjectsProperties[i].poolAmount);
                                        }
                                    }

                                    EditorGUILayout.Space();
                                    // WillGrow
                                    t.poolObjectsProperties[i].allowGrowth = EditorTools.Toggle("Allow growth", t.poolObjectsProperties[i].allowGrowth);

                                    EditorGUILayout.BeginHorizontal();
                                    t.poolObjectsProperties[i].limitGrowth = EditorTools.Toggle("Limit growth", t.poolObjectsProperties[i].limitGrowth);
                                    if (t.poolObjectsProperties[i].limitGrowth)
                                    {
                                        t.poolObjectsProperties[i].limit = EditorGUILayout.IntField("", t.poolObjectsProperties[i].limit, GUILayout.Width(50));
                                        if (t.poolObjectsProperties[i].limit < t.poolObjectsProperties[i].poolAmount)
                                        {
                                            t.poolObjectsProperties[i].limit = t.poolObjectsProperties[i].poolAmount;
                                        }
                                    }
                                    EditorGUILayout.EndHorizontal();

                                    EditorGUI.indentLevel--;
                                } EditorTools.EndGroup();
                            }
                        }
                    }
                } EditorTools.EndGroup();
            }

            if (GUI.changed && !EditorApplication.isPlaying)
            {
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            tools.StartGUI();

            tools.StartEdit(manager, "Changed Glass Render Order");

            listColourIndex = 0;
            list.DoLayoutList();
            GUI.backgroundColor = Color.white;

            if (tools.Button("Clean Up (no data loss)"))
            {
                GlassRenderOrderManager.Instance.RefreshGlassTypes();
                listModified = true;
            }

            if (listModified)
            {
                manager.RenderOrderFromOrder();
                manager.SortByRenderOrder();
                manager.UpdateMaterials();
                //manager.RefreshGlassTypes();

                /*
                 * tools.SetDirty(manager);
                 * tools.SetDirty(GlassManager.Instance);
                 */
                listModified = false;
            }

            tools.FinishEdit(manager);

            /*
             *
             * tools.Label("Order - Name - (Copy) - Queue - [Copy]");
             *
             * foreach (GlassType g in manager.glassTypes)
             * {
             *  tools.Label(g.presetName + " : " + g.renderOrder);
             * }
             *
             * if (tools.Button("Sort By Render Order"))
             * {
             *  manager.SortByRenderOrder();
             * }
             *
             * if (tools.Button("Render Order From Sorting Order"))
             * {
             *  manager.RenderOrderFromOrder();
             * }
             *
             * if (tools.Button("Find"))
             * {
             *  manager.FindGlassTypes();
             * }
             *
             * if (tools.Button("Refresh"))
             * {
             *  manager.RefreshGlassTypes();
             * }
             *
             */

            tools.EndGUI();
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            if (folderLoaded)
            {
                EditorTools.Message_static("Loading Complete", "Loaded " + modelCount.ToString() + " models from 'Assets/" + folderString + ".");
                folderLoaded    = false;
                folderString    = "";
                filePathsToLoad = null;
            }

            DrawDefaultInspector();

            if (tools.Button("Load Folder"))
            {
                if (tools.Message("Load Baked Animation In Folder", "Select one of the models in the folder you wish to load.", "OK", "Cancel"))
                {
                    EditorGUIUtility.ShowObjectPicker <GameObject>(null, false, "", objectPickerID);
                }
                GUIUtility.ExitGUI();
            }

            Event currentEvent = Event.current;

            if (currentEvent.type == EventType.ExecuteCommand || currentEvent.type == EventType.ValidateCommand)
            {
                if (currentEvent.commandName == "ObjectSelectorClosed")
                {
                    if (EditorGUIUtility.GetObjectPickerControlID() == objectPickerID)
                    {
                        Object pickedObject = EditorGUIUtility.GetObjectPickerObject();

                        if (pickedObject != null)
                        {
                            folderString = AssetDatabase.GetAssetPath(pickedObject);
                            folderString = folderString.Replace(Path.GetFileName(folderString), "");
                            folderString = folderString.Replace("Assets/", "");

                            filePathsToLoad = Directory.GetFiles(Application.dataPath + "/" + folderString);

                            bool replaceExisting = tools.Message("Load Folder", "Replace any existing models?", "Yes", "No");

                            tools.StartEdit(animator, "Mesh Animator Loaded models");

                            if (replaceExisting)
                            {
                                animator.models.Clear();
                            }

                            modelCount = animator.LoadFromFolder(filePathsToLoad, folderString);

                            tools.EndEdit(animator);

                            folderLoaded = true;

                            GUIUtility.ExitGUI();
                        }
                    }
                }
            }

            if (animator.paused)
            {
                if (tools.Button("Play"))
                {
                    animator.Play();
                }
            }
            else
            {
                if (tools.Button("Pause"))
                {
                    animator.Pause();
                }
            }
        }
コード例 #4
0
        void Section_Glass()
        {
            tools.StartChangeCheck();
            if (tools.ShowSection("Glass (" + manager.glass.Count + ")", ref manager.showGlass))
            {
                tools.GUI_List("Glass in Scene", ref manager.glass, ref manager.showGlassList, ref manager.scrollGlassList);

                /*
                 * tools.Label("The following list can also define the Render Order, where enabled. Lower = Earlier.", true);
                 * tools.StartChangeCheck();
                 * tools.BoolOption("Custom Render Order", ref manager.customRenderOrder);
                 * if(tools.EndChangeCheck())
                 * {
                 *      if(!manager.customRenderOrder)
                 *      {
                 *              manager.CustomRenderOrderDisabled();
                 *      }
                 * }
                 * tools.StartChangeCheck();
                 * int movedObjectCurrentIndex = -1;
                 * int movedObjectPreviousIndex = -1;
                 * tools.GUI_ReorderableList("Objects in Scene", ref manager.glass, ref manager.showGlassList, ref manager.scrollGlassList,
                 *                        ref movedObjectCurrentIndex, ref movedObjectPreviousIndex,
                 *                        "First", "Last");
                 * if(tools.EndChangeCheck())
                 * {
                 *      manager.UpdateGlassOrder_ByIndex(movedObjectCurrentIndex, movedObjectPreviousIndex);
                 * }
                 */

                if (tools.Button("Add from Scene (ignores duplicates)"))
                {
                    manager.FindGlass();
                }

                if (tools.ShowSection("Synchronised Settings", ref manager.showSynchroniseSettings))
                {
                    tools.StartEdit(manager, "Changed Glass Sync Settings");

                    tools.BoolOption("Synchronise Glass", ref manager.synchroniseGlass);
                    tools.Label("The following options define how Glass objects are synchronised.\nWhen a Glass object is modified its settings are copied to any matches.", true);
                    tools.BoolOption("Match by Glass Name", ref manager.matchByGlassName);
                    tools.BoolOption("Match by Materials", ref manager.matchByMaterial);

                    tools.FinishEdit(manager);

                    tools.EndSection();
                }
                tools.EndSection(true);
            }
            if (tools.EndChangeCheck())
            {
                manager.FindGlass();
            }
        }