コード例 #1
0
        /// <summary>
        /// Returns true if the control is valid in the current Event context.
        /// </summary>
        public static bool IsDragControl(InspectorDragControl control)
        {
            Event e = Event.current;

            if (control == InspectorDragControl.None || e == null)
            {
                return(false);
            }
            else if (control == InspectorDragControl.Drag)
            {
                return(true);
            }
            else if (control == InspectorDragControl.AltDrag && e.alt)
            {
                return(true);
            }
            else if (control == InspectorDragControl.ControlDrag && e.control)
            {
                return(true);
            }
            else if (control == InspectorDragControl.ShiftDrag && e.shift)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        private static InspectorDragControl Next(InspectorDragControl control)
        {
            if (control == InspectorDragControl.None)
            {
                return(InspectorDragControl.None);
            }

            switch (control)
            {
            case InspectorDragControl.Drag:
                return(InspectorDragControl.AltDrag);

            case InspectorDragControl.AltDrag:
                return(InspectorDragControl.ControlDrag);

            case InspectorDragControl.ControlDrag:
                return(InspectorDragControl.ShiftDrag);

            case InspectorDragControl.ShiftDrag:
                return(InspectorDragControl.Drag);
            }

            return(InspectorDragControl.None);
        }
コード例 #3
0
        private static void Preference()
        {
            tool = GUILayout.Toolbar(tool, new string[] { "Preferences", "Editors", "About" });

            if (tool == 0)
            {
                EditorGUI.BeginChangeCheck();
                inspectDefaultItems  = EditorGUILayout.Toggle(new GUIContent("Inspect Default Items", "Draws all types that do not have a Custom Editor associated. If false, your classes are drawn by Unity unless they have the AdvancedInspector attribute."), inspectDefaultItems);
                expandableReferences = EditorGUILayout.Toggle(new GUIContent("Expandable References", "All MonoBehaviour/ScriptableObject references are expandable from the displayed field."), expandableReferences);

                collectionItemNaming = (InspectorCollectionItemNaming)EditorGUILayout.EnumPopup(new GUIContent("Collection Naming", "How items in a collection are named."), collectionItemNaming);

                valueScroll = (InspectorDragControl)EditorGUILayout.EnumPopup("Number Drag", valueScroll);
                if (valueScroll == copyPaste)
                {
                    copyPaste = Next(copyPaste);
                }

                copyPaste = (InspectorDragControl)EditorGUILayout.EnumPopup("Copy/Paste Drag", copyPaste);
                if (valueScroll == copyPaste)
                {
                    valueScroll = Next(valueScroll);
                }

#if UNITY_2017_1 || UNITY_2017_2
                massExpand = (InspectorModifierControl)EditorGUILayout.EnumMaskField("Expand/Collapse Children", massExpand);

                contextual = (InspectorModifierControl)EditorGUILayout.EnumMaskField("Contextual Menu", contextual);
#else
                massExpand = (InspectorModifierControl)EditorGUILayout.EnumFlagsField("Expand/Collapse Children", massExpand);

                contextual = (InspectorModifierControl)EditorGUILayout.EnumFlagsField("Contextual Menu", contextual);
#endif

                extraIndentation = Mathf.Clamp(EditorGUILayout.IntField("Indentation", extraIndentation), 0, int.MaxValue);
                largeCollection  = Mathf.Clamp(EditorGUILayout.IntField("Large Collection", largeCollection), 10, 200);

                separator              = (SeparatorStyle)EditorGUILayout.EnumPopup("Separator", separator);
                separatorDefaultColor  = EditorGUILayout.ColorField("Separator Default", separatorDefaultColor);
                separatorSelectedColor = EditorGUILayout.ColorField("Separator Selected", separatorSelectedColor);
                boxDefaultColor        = EditorGUILayout.ColorField("Box Default", boxDefaultColor);
                boxPlayColor           = EditorGUILayout.ColorField("Box Playmode", boxPlayColor);

                style = (InspectorStyle)EditorGUILayout.EnumPopup("Style", style);

                Color previous = GUI.color;
                GUI.color = EditorApplication.isPlaying ? boxPlayColor : boxDefaultColor;

                GUILayout.Box("", AdvancedInspectorControl.BoxTitleStyle);
                GUILayout.Box("", AdvancedInspectorControl.BoxStyle);

                GUI.color = previous;

                if (EditorGUI.EndChangeCheck())
                {
                    EditorPrefs.SetBool(InspectDefaultItemsKey, inspectDefaultItems);
                    EditorPrefs.SetInt(StyleKey, (int)style);
                    EditorPrefs.SetInt(SeparatorKey, (int)separator);
                    EditorPrefs.SetString(SeparatorDefaultKey, ColorToString(separatorDefaultColor));
                    EditorPrefs.SetString(SeparatorSelectedKey, ColorToString(separatorSelectedColor));
                    EditorPrefs.SetString(BoxDefaultKey, ColorToString(boxDefaultColor));
                    EditorPrefs.SetString(BoxPlayKey, ColorToString(boxPlayColor));
                    EditorPrefs.SetInt(IndentationKey, extraIndentation);
                    EditorPrefs.SetInt(LargeCollectionKey, largeCollection);
                    EditorPrefs.SetInt(ValueScrollKey, (int)valueScroll);
                    EditorPrefs.SetInt(CopyPasteKey, (int)copyPaste);
                    EditorPrefs.SetInt(MassExpandKey, (int)massExpand);
                    EditorPrefs.SetBool(ExpandableReferencesKey, expandableReferences);
                    EditorPrefs.SetInt(CollectionItemNamingKey, (int)collectionItemNaming);
                }
            }
            else if (tool == 1)
            {
                bool offAll = false;
                bool onAll  = false;

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Turn Off"))
                {
                    offAll = true;
                }

                if (GUILayout.Button("Turn On"))
                {
                    onAll = true;
                }
                GUILayout.EndHorizontal();

                bool changed = false;
                scrollView = GUILayout.BeginScrollView(scrollView);
                foreach (KeyValuePair <FileInfo, string[]> pair in editors)
                {
                    bool active = !pair.Value[0].Contains("///");
                    bool result = EditorGUILayout.ToggleLeft(pair.Key.Name, active);

                    if (offAll)
                    {
                        result = false;
                    }

                    if (onAll)
                    {
                        result = true;
                    }

                    if (result != active)
                    {
                        if (!result)
                        {
                            for (int i = 0; i < pair.Value.Length; i++)
                            {
                                pair.Value[i] = "///" + pair.Value[i];
                            }
                        }
                        else
                        {
                            for (int i = 0; i < pair.Value.Length; i++)
                            {
                                pair.Value[i] = pair.Value[i].Substring(3);
                            }
                        }

                        string path = "Assets" + pair.Key.FullName.Substring(Application.dataPath.Length);
                        if (!AssetDatabase.IsOpenForEdit(path, StatusQueryOptions.UseCachedIfPossible))
                        {
                            Provider.Checkout(path, CheckoutMode.Both);
                        }

                        File.WriteAllLines(pair.Key.FullName, pair.Value);
                        UnityEngine.Object[] selection = Selection.objects;
                        Selection.objects = new UnityEngine.Object[0];
                        Selection.objects = selection;
                        changed           = true;
                    }
                }
                GUILayout.EndScrollView();

                if (changed)
                {
                    AssetDatabase.Refresh();
                }
            }
            else if (tool == 2)
            {
                GUIStyle style = new GUIStyle();
                style.normal.textColor = Color.blue;

                GUI.DrawTexture(new Rect(-16, 36, 379, 93), Logo, ScaleMode.ScaleToFit);

                GUILayout.Space(100);

                EditorGUILayout.LabelField(version);

                GUILayout.Space(10);

                if (GUILayout.Button("Manual", style))
                {
                    Application.OpenURL("http://lightstrikersoftware.com/docs/AdvancedInspector_Manual.pdf");
                }

                GUILayout.Space(10);

                if (GUILayout.Button("Tutorials", style))
                {
                    Application.OpenURL("http://lightstrikersoftware.com/docs/AdvancedInspector_Tutorials.pdf");
                }

                GUILayout.Space(10);
                EditorGUILayout.LabelField("Need Help? Found A Bug?");

                if (GUILayout.Button("*****@*****.**", style))
                {
                    Application.OpenURL("mailto:[email protected]");
                }
            }
        }
コード例 #4
0
        static InspectorPreferences()
        {
            if (EditorPrefs.HasKey(InspectDefaultItemsKey))
            {
                inspectDefaultItems = EditorPrefs.GetBool(InspectDefaultItemsKey);
            }

            if (EditorPrefs.HasKey(StyleKey))
            {
                style = (InspectorStyle)EditorPrefs.GetInt(StyleKey);
            }

            if (EditorPrefs.HasKey(SeparatorKey))
            {
                separator = (SeparatorStyle)EditorPrefs.GetInt(SeparatorKey);
            }

            if (EditorPrefs.HasKey(SeparatorDefaultKey))
            {
                separatorDefaultColor = StringToColor(EditorPrefs.GetString(SeparatorDefaultKey));
            }

            if (EditorPrefs.HasKey(SeparatorSelectedKey))
            {
                separatorSelectedColor = StringToColor(EditorPrefs.GetString(SeparatorSelectedKey));
            }

            if (EditorPrefs.HasKey(BoxDefaultKey))
            {
                boxDefaultColor = StringToColor(EditorPrefs.GetString(BoxDefaultKey));
            }

            if (EditorPrefs.HasKey(BoxPlayKey))
            {
                boxPlayColor = StringToColor(EditorPrefs.GetString(BoxPlayKey));
            }

            if (EditorPrefs.HasKey(IndentationKey))
            {
                extraIndentation = EditorPrefs.GetInt(IndentationKey);
            }

            if (EditorPrefs.HasKey(LargeCollectionKey))
            {
                largeCollection = EditorPrefs.GetInt(LargeCollectionKey);
            }

            if (EditorPrefs.HasKey(ValueScrollKey))
            {
                valueScroll = (InspectorDragControl)EditorPrefs.GetInt(ValueScrollKey);
            }

            if (EditorPrefs.HasKey(CopyPasteKey))
            {
                copyPaste = (InspectorDragControl)EditorPrefs.GetInt(CopyPasteKey);
            }

            if (EditorPrefs.HasKey(MassExpandKey))
            {
                massExpand = (InspectorModifierControl)EditorPrefs.GetInt(MassExpandKey);
            }

            if (EditorPrefs.HasKey(ContextualKey))
            {
                contextual = (InspectorModifierControl)EditorPrefs.GetInt(ContextualKey);
            }

            if (EditorPrefs.HasKey(ExpandableReferencesKey))
            {
                expandableReferences = EditorPrefs.GetBool(ExpandableReferencesKey);
            }

            if (EditorPrefs.HasKey(CollectionItemNamingKey))
            {
                collectionItemNaming = (InspectorCollectionItemNaming)EditorPrefs.GetInt(CollectionItemNamingKey);
            }

            GetAllEditor();
        }