Esempio n. 1
0
        private void OnGUI()
        {
            this.Focus();
            this.wantsMouseMove = true;

            if (InstanceCreator.Type == null)
            {
                this.Close();
                return;
            }
            else
            {
                this.RootNode = this.RootNode ?? this.GetTypeTree(InstanceCreator.Type);

                AllEditorGUI.BeginHorizontalToolbar(ToolbarBackgroundChainedTop);
                {
                    this.searchChanged = this.searchTerm != (this.searchTerm = AllEditorGUI.ToolbarSearchField(this.searchTerm, true)) || this.searchChanged;
                }
                AllEditorGUI.EndHorizontalToolbar();

                AllEditorGUI.BeginVerticalMenuList(this);
                {
                    this.RootNode.DrawItem();
                }
                AllEditorGUI.EndVerticalMenuList();

                AllEditorGUI.DrawBorders(new Rect(0, 0, this.position.width, this.position.height), 1, 1, 1, 1, SirenixGUIStyles.BorderColor);

                if (Event.current.type == EventType.Repaint)
                {
                    this.hasSearchTerm = this.searchTerm != null && (this.searchTerm.Length >= 2 || (this.searchTerm.Length == 1 && !char.IsLetter(this.searchTerm[0])));

                    if (this.searchChanged)
                    {
                        this.RootNode.UpdateSearchTerm();

                        this.searchChanged = false;
                    }
                }

                if (this.chosenType != null)
                {
                    this.SetSelectedType();
                    this.chosenType = null;
                    this.Close();
                    return;
                }

                this.RepaintIfRequested();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <InspectorTypeDrawingConfig> entry, GUIContent label)
        {
            var searchLabel = entry.Context.Get(this, "searchLabel", (GUIContent)null);
            var searchText  = entry.Context.Get(this, "searchText", "");
            var displayType = entry.Context.Get(this, "displayType", DisplayType.AllUnityObjects);
            var scrollPos   = entry.Context.Get(this, "scrollPos", Vector2.zero);

            //var autoRecompileOnChangesDetected = entry.Property.Tree.GetPropertyAtPath("autoRecompileOnChangesDetected").ValueEntry as IPropertyValueEntry<bool>;

            //var defaultEditorBehaviour = entry.Property.Tree.GetPropertyAtPath("defaultEditorBehaviour").ValueEntry as PropertyValueEntry<InspectorDefaultEditorBehaviour>;
            //var processMouseMoveInInspector = entry.Property.Tree.GetPropertyAtPath("processMouseMoveInInspector").ValueEntry as PropertyValueEntry<bool>;

            if (searchLabel.Value == null)
            {
                searchLabel.Value = new GUIContent("Filter");
            }

            //GUILayout.BeginHorizontal();

            ////const string autoRecompileString = " Rebuild editors automatically when changes are detected";

            ////if (autoRecompileOnChangesDetected.SmartValue)
            ////{
            ////    autoRecompileOnChangesDetected.SmartValue = GUILayout.Toggle(autoRecompileOnChangesDetected.SmartValue, autoRecompileString);
            ////}
            ////else
            ////{
            ////    GUILayout.BeginVertical();
            ////    {
            ////        autoRecompileOnChangesDetected.SmartValue = GUILayout.Toggle(autoRecompileOnChangesDetected.SmartValue, autoRecompileString);
            ////        AllEditorGUI.WarningMessageBox("Note that with automatic rebuilding disabled, you may get error messages from Unity on startup, stating that inspected types have gone missing. While annoying, this is expected behaviour, and can be safely ignored.");
            ////    }
            ////    GUILayout.EndVertical();
            ////}

            //GUILayout.FlexibleSpace();

            //if (GUILayout.Button("Update Editors"))
            //{
            //    //AssetDatabase.SaveAssets();
            //    //AssetDatabase.Refresh();
            //    //EditorApplication.delayCall += () => EditorCompilation.CompileEditors(GetEditors());

            //    InspectorConfig.Instance.UpdateOdinEditors();
            //}
            ////if (GUILayout.Button("Recompile Editors"))
            ////{
            ////    AssetDatabase.SaveAssets();
            ////    AssetDatabase.Refresh();
            ////    EditorApplication.delayCall += () => EditorCompilation.CompileEditors(GetEditors());
            ////}
            //GUILayout.EndHorizontal();
            //GUILayout.Space(10);

            AllEditorGUI.BeginHorizontalToolbar();
            GUILayout.Label("Draw ODIN for", GUILayoutOptions.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            AllEditorGUI.VerticalLineSeparator();

            GUI.changed      = false;
            searchText.Value = AllEditorGUI.ToolbarSearchField(searchText.Value, true);
            if (GUI.changed)
            {
                UpdateRootGroupsSearch(searchText.Value, displayType.Value);
            }

            if (AllEditorGUI.ToolbarButton(new GUIContent(" Reset to default ")))
            {
                var asset = InspectorConfig.Instance;

                if (EditorUtility.DisplayDialog("Reset " + asset.name + " to default", "Are you sure you want to reset all settings on " + asset.name + " to default values? This cannot be undone.", "Yes", "No"))
                {
                    AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(asset));
                    AssetDatabase.Refresh();
                    UnityEngine.Object.DestroyImmediate(asset);
                }
            }
            AllEditorGUI.EndHorizontalToolbar();
            AllEditorGUI.BeginVerticalList(true, false, GUILayoutOptions.ExpandHeight(false));
            {
                scrollPos.Value = EditorGUILayout.BeginScrollView(scrollPos.Value, GUILayoutOptions.ExpandWidth(true));
                {
                    DrawRootTypeGroup(InspectorDefaultEditors.UserTypes, entry, searchText.Value);
                    DrawRootTypeGroup(InspectorDefaultEditors.PluginTypes, entry, searchText.Value);
                    DrawRootTypeGroup(InspectorDefaultEditors.UnityTypes, entry, searchText.Value);
                    DrawRootTypeGroup(InspectorDefaultEditors.OtherTypes, entry, searchText.Value);
                }
                EditorGUILayout.EndScrollView();
            }
            AllEditorGUI.EndVerticalList();
        }