public void DrawNavigationHistory(Rect rect)
        {
            GUIHelpers.IsInspector = false;
            if (Drawer == null)
            {
                return;
            }
            if (_updateRequired)
            {
                UpdateItems();
                _updateRequired = false;
            }

            Drawer.DrawStretchBox(rect, CachedStyles.WizardListItemBoxStyle, 10);


            if (!NavHistoryItems.Any())
            {
                var textRect   = rect;
                var cacheColor = GUI.color;
                GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.4f);
                Drawer.DrawLabel(textRect, "No History", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter);
                GUI.color = cacheColor;
                return;
            }


            var clearButton = new Rect().WithSize(80, 33).InnerAlignWithBottomRight(rect).PadSides(5);

            Drawer.DoButton(clearButton, "Clear", ElementDesignerStyles.ButtonStyle,
                            m =>
            {
                Execute(new LambdaCommand("Clear Navigation History", () =>
                {
                    Repository.RemoveAll <NavHistoryItem>();
                }));
            });

            if (NavHistoryTree == null)
            {
                return;
            }
            if (NavHistoryTree.IsDirty)
            {
                NavHistoryTree.Refresh();
            }

            Signal <IDrawTreeView>(_ => _.DrawTreeView(rect.AddHeight(-28).PadSides(5), NavHistoryTree, (m, i) =>
            {
                var bp = i as NavHistoryItem;
                if (bp != null)
                {
                    Execute(new NavigateByHistoryItemCommand()
                    {
                        Item = bp,
                    });
                }
            }));
        }
        public void DrawActionDialog(IPlatformDrawer platform, Rect bounds, ActionItem item, System.Action cancel = null)
        {
            if (item == null)
            {
                return;
            }

            platform.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13);

            bounds = bounds.PadSides(15);

            var descriptionHeight = string.IsNullOrEmpty(item.Description) ? 50 : platform.CalculateTextHeight(item.Description, CachedStyles.BreadcrumbTitleStyle, bounds.width) + 60;

            var headerRect = bounds.WithHeight(40);
            var iconRect   = bounds.WithSize(41, 41);

            var descriptionRect   = headerRect.Below(headerRect).Translate(0, -22).WithHeight(descriptionHeight);
            var inspectorRect     = bounds.Below(descriptionRect).Clip(bounds);
            var executeButtonRect = new Rect()
                                    .WithSize(100, 30)
                                    .InnerAlignWithBottomRight(bounds);

            if (!_inspectors.ContainsKey(item))
            {
                var uFrameMiniInspector = new uFrameMiniInspector(item.Command);
                _inspectors.Add(item, uFrameMiniInspector);
            }
            var inspector       = _inspectors[item];
            var inspectorHeight = inspector.Height;


            _scrollPosition = GUI.BeginScrollView(bounds.AddHeight(-30).AddWidth(15), _scrollPosition,
                                                  bounds.WithHeight(headerRect.height + iconRect.height + descriptionRect.height + inspectorHeight));

            platform.DrawLabel(headerRect, item.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter);
            platform.DrawImage(iconRect, string.IsNullOrEmpty(item.Icon) ? "CreateEmptyDatabaseIcon" : item.Icon, true);
            platform.DrawLabel(descriptionRect, item.Description, CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.MiddleLeft);

            inspector.Draw(descriptionRect.WithHeight(inspectorHeight).Pad(0, 0, 10, 0).Below(descriptionRect));

            //Draw generic inspector


            GUI.EndScrollView();
            if (cancel != null)
            {
                platform.DoButton(executeButtonRect.InnerAlignWithBottomLeft(bounds), "Cancel", ElementDesignerStyles.DarkButtonStyle, cancel);
            }

            platform.DoButton(executeButtonRect, string.IsNullOrEmpty(item.Verb) ? "Create" : item.Verb, ElementDesignerStyles.DarkButtonStyle, () =>
            {
                InvertApplication.Execute(item.Command);
            });
        }
Пример #3
0
        public override void OnInspectorGUI()
        {
            EditorUI.Reset();
            ProxyEditor.GetInspector(this).SetTitle(this.title);
            ProxyEditor.GetInspectors().ForEach(x => x.wantsMouseMove = true);
            if (!Event.current.IsUseful())
            {
                return;
            }
            if (this.target is MonoBehaviour && this.target.As <MonoBehaviour>().InPrefabFile())
            {
                return;
            }
            this.BeginArea();
            bool fastInspector = EditorPref.Get <bool>("MonoBehaviourEditor-FastInspector");

            /*if(fastInspector && MonoBehaviourEditor.offScreen.ContainsKey(this)){
             *      GUILayout.Space(this.area.height);
             *      this.CheckChanges();
             *      return;
             * }*/
            if (Event.current.type == EventType.MouseMove)
            {
                Call.Delay(ProxyEditor.RepaintInspectors, 0.1f);
            }
            bool hideAllDefault = EditorPref.Get <bool>("MonoBehaviourEditor-HideAllDefault", false);

            this.hideDefault = EditorPref.Get <bool>("MonoBehaviourEditor-" + this.target.GetInstanceID() + "HideDefault", false);
            bool hideDefault = hideAllDefault || this.hideDefault;

            if (hideDefault)
            {
                this.SortDefaults();
            }
            this.serializedObject.Update();
            this.SortProperties();
            this.Setup();
            Type type = this.target.GetType();

            this.changed = false;
            bool showAdvanced   = EditorPref.Get <bool>("MonoBehaviourEditor-Advanced");
            bool showInternal   = EditorPref.Get <bool>("MonoBehaviourEditor-Internal");
            bool showDictionary = EditorPref.Get <bool>("MonoBehaviourEditor-Dictionary");

            EditorGUILayout.BeginVertical();
            foreach (var property in this.properties)
            {
                string[] attributes = this.serializedObject.targetObject.ListAttributes(property.name).Select(x => x.GetType().Name).ToArray();
                bool     isInternal = attributes.Contains("InternalAttribute");
                bool     isAdvanced = attributes.Contains("AdvancedAttribute");
                bool     isReadOnly = isInternal || attributes.Contains("ReadOnlyAttribute");
                bool     isHidden   = !this.showAll && this.hidden.Contains(property);
                if (isAdvanced && !showAdvanced)
                {
                    isHidden = true;
                }
                if (isInternal && !showInternal)
                {
                    isHidden = true;
                }
                object currentValue = property.GetObject <object>();
                bool   hasDefault   = MonoBehaviourEditor.defaults.ContainsKey(type) && MonoBehaviourEditor.defaults[type].ContainsKey(property.name);
                if (!this.showAll && hideDefault && hasDefault)
                {
                    object defaultValue = MonoBehaviourEditor.defaults[type][property.name];
                    if (defaultValue.IsNull())
                    {
                        continue;
                    }
                    bool isDefault = defaultValue.Equals(currentValue);
                    if (isDefault)
                    {
                        isHidden = true;
                    }
                }
                if (!isHidden)
                {
                    bool hasArea = this.propertyArea.ContainsKey(property);
                    if (hasArea)
                    {
                        if (Event.current.shift)
                        {
                            bool canHide = (this.properties.Count - this.hidden.Count) > 1;
                            if (this.propertyArea[property].Clicked(0) && canHide)
                            {
                                string path = "MonoBehaviourEditor-PropertyHide-" + this.target.GetInstanceID() + "-" + property.propertyPath;
                                EditorPref.Set <bool>(path, true);
                                this.hidden.Add(property);
                            }
                            if (this.propertyArea[property].Clicked(1))
                            {
                                this.DrawMenu();
                            }
                        }
                        if (fastInspector && this.propertyVisible.ContainsKey(property) && !this.propertyVisible[property])
                        {
                            GUILayout.Space(this.propertyArea[property].height);
                            continue;
                        }
                    }
                    string propertyName = null;
                    if (isReadOnly)
                    {
                        GUI.enabled = false;
                    }
                    GUI.changed = false;
                    EditorGUILayout.BeginVertical();
                    if (hasArea)
                    {
                        EditorGUI.BeginProperty(this.propertyArea[property], new GUIContent(property.displayName), property);
                    }
                    property.Draw(propertyName);
                    if (hasArea)
                    {
                        EditorGUI.EndProperty();
                    }
                    EditorGUILayout.EndVertical();
                    this.changed = this.changed || GUI.changed;
                    if (isReadOnly)
                    {
                        GUI.enabled = true;
                    }
                    if (Proxy.IsRepainting())
                    {
                        Rect area = GUILayoutUtility.GetLastRect();
                        if (!area.IsEmpty())
                        {
                            this.propertyArea[property] = area.AddHeight(2);
                        }
                    }
                }
            }
            if (showDictionary)
            {
                GUI.enabled = false;
                foreach (var item in this.dictionaries)
                {
                    item.Value.DrawAuto(item.Key, null, true);
                }
                GUI.enabled = true;
            }
            EditorGUILayout.EndVertical();
            this.EndArea();
            if (this.changed)
            {
                this.serializedObject.ApplyModifiedProperties();
                //this.serializedObject.targetObject.CallMethod("OnValidate");
                ProxyEditor.SetDirty(this.serializedObject.targetObject, false, true);
            }
            this.CheckChanges();
            if (Proxy.IsRepainting())
            {
                ProxyEditor.GetInspector(this).SetTitle("Inspector");
            }
        }