Ejemplo n.º 1
0
        public static void Main()
        {
            GUIContent fastInspectorHelp         = new GUIContent("Turbo Inspector (Experimental)");
            GUIContent alwaysUpdateShadersHelp   = new GUIContent("Always Update Shaders");
            GUIContent alwaysUpdateParticlesHelp = new GUIContent("Always Update Particles");
            GUIContent particleUpdateRangeHelp   = new GUIContent("Always Update Particles (Range)");

            fastInspectorHelp.tooltip         = "Prevents offscreen attributes/components from being drawn in inspectors. ";
            fastInspectorHelp.tooltip        += "Currently has issues with multiple inspectors visible and erratic nudging position offset issues while scrolling.";
            alwaysUpdateShadersHelp.tooltip   = "Forces the scene view to repaint every frame.  Huge performance cost, but will allow shaders based on time to update in realtime.";
            alwaysUpdateParticlesHelp.tooltip = "Forces the scene view to repaint every frame.  Huge performance cost, but will continually ensure particles are simulated.";
            particleUpdateRangeHelp.tooltip   = "Range at which editor-updated particles will simulate.  Higher values will cost more performance.";
            if ("Other".ToLabel().DrawFoldout("Zios.Preferences.Other"))
            {
                EditorGUI.indentLevel += 1;
                bool  fastInspector         = EditorPref.Get <bool>("MonoBehaviourEditor-FastInspector").Draw(fastInspectorHelp);
                bool  alwaysUpdateShaders   = EditorPref.Get <bool>("EditorSettings-AlwaysUpdateShaders").Draw(alwaysUpdateShadersHelp);
                bool  alwaysUpdateParticles = EditorPref.Get <bool>("EditorSettings-AlwaysUpdateParticles").Draw(alwaysUpdateParticlesHelp);
                float particleUpdateRange   = EditorPref.Get <float>("EditorSettings-ParticleUpdateRange", 100).Draw(particleUpdateRangeHelp);
                if (GUI.changed)
                {
                    EditorPref.Set <bool>("MonoBehaviourEditor-FastInspector", fastInspector);
                    EditorPref.Set <bool>("EditorSettings-AlwaysUpdateShaders", alwaysUpdateShaders);
                    EditorPref.Set <bool>("EditorSettings-AlwaysUpdateParticles", alwaysUpdateParticles);
                    EditorPref.Set <float>("EditorSettings-ParticleUpdateRange", particleUpdateRange);
                }
                EditorGUI.indentLevel -= 1;
            }
        }
Ejemplo n.º 2
0
        public virtual void Setup(AttributeDrawer drawer, Rect area, SerializedProperty property, GUIContent label)
        {
            string skinName = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false) ? "Dark" : "Light";

            if (this.skin == null || !this.skin.name.Contains(skinName))
            {
                this.skin      = File.GetAsset <GUISkin>("Gentleface-" + skinName + ".guiskin");
                this.attribute = property.GetObject <Attribute>();
            }
            var info = this.attribute.info;

            this.activeDataset = info.data;
            this.drawer        = drawer;
            this.property      = property;
            this.label         = label;
            Rect fullRect = area.SetHeight(EditorGUIUtility.singleLineHeight);

            this.SetupAreas(fullRect);
            ProxyEditor.RecordObject(info.parent, "Attribute Changes");
            this.Draw();
            if (GUI.changed || this.dirty)
            {
                this.attribute.Setup(info.relativePath, info.parent);
                info.parent.DelayEvent(info.fullPath, "On Validate", 1);
                property.serializedObject.Update();
                ProxyEditor.SetDirty(info.parent);
                ProxyEditor.RepaintInspectors();
                this.dirty  = false;
                GUI.changed = true;
            }
        }
Ejemplo n.º 3
0
        public void LoadSettings()
        {
            string name      = MaterialBuffer.material.name;
            bool   firstOpen = !EditorPref.Has(name + "-Material");

            MaterialBuffer.options["ShowDefault"] = firstOpen ? true : EditorPref.Get <int>("ExtendedMaterial-ShowDefault").ToBool();
            MaterialBuffer.options["ShowPreview"] = firstOpen ? true : EditorPref.Get <int>("ExtendedMaterial-ShowPreview").ToBool();
            MaterialBuffer.options["ShaderUnity"] = EditorPref.Get <int>(name + "-ShaderUnity").ToBool();
            MaterialBuffer.options["ShaderGPU"]   = EditorPref.Get <int>(name + "-ShaderGPU").ToBool();
            MaterialBuffer.options["Properties"]  = EditorPref.Get <int>(name + "-Properties").ToBool();
            MaterialBuffer.options["Material"]    = firstOpen ? true : EditorPref.Get <int>(name + "-Material").ToBool();
            int shaderIndex = 0;
            int passIndex   = 0;

            foreach (SubShader subShader in MaterialBuffer.active.subShaders)
            {
                shaderIndex += 1;
                string shaderHash = "Sub" + shaderIndex;
                MaterialBuffer.options[shaderHash]          = firstOpen ? true : EditorPref.Get <int>(name + "-" + shaderHash).ToBool();
                MaterialBuffer.options[shaderHash + "Tags"] = EditorPref.Get <int>(name + "-" + shaderHash + "Tags").ToBool();
                MaterialBuffer.options[shaderHash + "Fog"]  = EditorPref.Get <int>(name + "-" + shaderHash + "Fog").ToBool();
                foreach (var item in subShader.passes)
                {
                    passIndex      += 1;
                    item.Value.name = item.Value.name;
                    string passHash = "Pass" + passIndex;
                    MaterialBuffer.options[passHash]          = firstOpen ? true : EditorPref.Get <int>(name + "-" + passHash).ToBool();
                    MaterialBuffer.options[passHash + "Tags"] = EditorPref.Get <int>(name + "-" + passHash + "Tags").ToBool();
                    MaterialBuffer.options[passHash + "Fog"]  = EditorPref.Get <int>(name + "-" + passHash + "Fog").ToBool();
                }
            }
        }
Ejemplo n.º 4
0
        public override void OnGUI(Rect area, SerializedProperty property, GUIContent label)
        {
            EditorUI.Reset();
            float singleLine = EditorGUIUtility.singleLineHeight;

            area = area.SetHeight(singleLine);
            bool expanded = EditorPref.Get <bool>("layerDistancesExpanded");

            expanded = EditorGUI.Foldout(area, expanded, "Layer Cull Distances");
            EditorPref.Set <bool>("layerDistancesExpanded", expanded);
            if (expanded)
            {
                EditorGUI.indentLevel += 1;
                this.drawn             = 0;
                float[] values = property.FindPropertyRelative("values").GetObject <float[]>();
                for (int index = 0; index < 32; index++)
                {
                    string layerName = LayerMask.LayerToName(index);
                    //if(layerName.IsEmpty()){layerName = "[Unnamed]";}
                    if (!layerName.IsEmpty())
                    {
                        area          = area.AddY(singleLine + 2);
                        values[index] = values[index].Draw(area, new GUIContent(layerName));
                        this.drawn   += 1;
                    }
                }
                EditorGUI.indentLevel -= 1;
            }
        }
Ejemplo n.º 5
0
        public static void RecordEnd(string operation, object target, Action <string> callback = null, bool handlePrefs = true)
        {
            Reflection.ResetCache();
            var undo = "";
            var redo = "";

            if (Undo.snapshot.ContainsKey(target))
            {
                var changes = Undo.snapshot[target].Difference(target.GetVariables(Reflection.staticPublicFlags));
                foreach (var item in changes)
                {
                    var scope = "&&&" + target.AsType().FullName + "###" + item.Key + "|||";
                    undo += scope + Undo.snapshot[target][item.Key];
                    redo += scope + item.Value;
                }
                Undo.snapshot.Remove(target);
            }
            if (handlePrefs)
            {
                foreach (var pref in Undo.snapshotPrefs)
                {
                    var current = EditorPref.Get(pref.Key, pref.Value);
                    var head    = "&&&" + pref.Key + "|||" + pref.Value.GetType().Name + "---";
                    undo += head + pref.Value.SerializeAuto();
                    redo += head + current.SerializeAuto();
                }
                Undo.snapshotPrefs.Clear();
            }
            undo = undo.ReplaceFirst("&&&", "").Trim();
            redo = redo.ReplaceFirst("&&&", "").Trim();
            Undo.Add(operation, undo, redo, Undo.Handle + callback);
        }
Ejemplo n.º 6
0
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     if (EditorPref.Get <bool>("layerDistancesExpanded"))
     {
         return(((EditorGUIUtility.singleLineHeight + 2) * this.drawn) + 16);
     }
     return(base.GetPropertyHeight(property, label));
 }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            var hash = property.GetObject <AttributeTransition>().path;

            if (EditorPref.Get <bool>(hash))
            {
                return(EditorGUIUtility.singleLineHeight * 5 + 8);
            }
            return(base.GetPropertyHeight(property, label));
        }
Ejemplo n.º 8
0
        public static void RecordPref <Type>(string name, Type value)
        {
            var current = EditorPref.Get <Type>(name, value);

            if (!current.IsNull() && !current.Equals(value))
            {
                Undo.snapshotPrefs[name] = current;
            }
            EditorPref.Set <Type>(name, value);
        }
Ejemplo n.º 9
0
 public override void Clicked(int button)
 {
     if (button == 0)
     {
         int mode = (EditorPref.Get <int>("StateWindow-Mode", 2) + 1) % 3;
         EditorPref.Set <int>("StateWindow-Mode", mode);
         this.row.table.ShowAll();
         StateWindow.Get().Repaint();
         return;
     }
 }
Ejemplo n.º 10
0
        public virtual void DrawDirect(Rect area, Rect extraArea, AttributeData data, GUIContent label, bool?drawSpecial = null, bool?drawOperator = null)
        {
            float labelSize = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = this.labelRect.width;
            bool showSpecial = drawSpecial != null && (EditorPref.Get <bool>(data.path + "Advanced") || data.special != 0);

            if (drawOperator != null)
            {
                EditorGUIUtility.labelWidth += 71;
            }
            if (showSpecial)
            {
                EditorGUIUtility.labelWidth += 91;
            }
            if (drawOperator != null)
            {
                this.DrawOperator(extraArea, data, (bool)!drawOperator);
                extraArea = extraArea.Add(51, 0, -51, 0);
            }
            if (showSpecial)
            {
                this.DrawSpecial(extraArea, data);
                area = area.Add(-41, 0, 41, 0);
            }
            if (data is AttributeFloatData)
            {
                AttributeFloatData floatData = (AttributeFloatData)data;
                floatData.Set(floatData.value.Draw(area, label));
            }
            if (data is AttributeIntData)
            {
                AttributeIntData intData = (AttributeIntData)data;
                intData.Set(intData.value.DrawInt(area, label, null, true));
            }
            if (data is AttributeStringData)
            {
                AttributeStringData stringData = (AttributeStringData)data;
                stringData.Set(stringData.value.Draw(area, label));
            }
            if (data is AttributeBoolData)
            {
                AttributeBoolData boolData = (AttributeBoolData)data;
                boolData.Set(boolData.value.Draw(area, label));
            }
            if (data is AttributeVector3Data)
            {
                AttributeVector3Data vector3Data = (AttributeVector3Data)data;
                vector3Data.Set(vector3Data.value.DrawVector3(area, label, true));
            }
            EditorGUIUtility.labelWidth = labelSize;
        }
Ejemplo n.º 11
0
        public override void DrawStyle()
        {
            var      window       = StateWindow.Get();
            var      row          = this.row.target.As <StateRow>();
            var      script       = row.target;
            bool     darkSkin     = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false);
            string   name         = this.target is string?(string)this.target : script.alias;
            string   background   = darkSkin ? "BoxBlackA30" : "BoxWhiteBWarm";
            Color    textColor    = darkSkin? Colors.Get("Silver") : Colors.Get("Black");
            GUIStyle style        = new GUIStyle(GUI.skin.label);
            GUIStyle expand       = Style.Get("buttonExpand", true);
            bool     fieldHovered = window.row == this.row.order;

            if (fieldHovered)
            {
                textColor  = darkSkin ? Colors.Get("ZestyBlue") : Colors.Get("White");
                background = darkSkin ? "BoxBlackHighlightBlueAWarm" : "BoxBlackHighlightBlueDWarm";
            }
            if (this.row.selected)
            {
                textColor  = darkSkin ? Colors.Get("White") : Colors.Get("White");
                background = darkSkin ? "BoxBlackHighlightCyanA" : "BoxBlackHighlightCyanCWarm";
            }
            style.fixedWidth       -= 28;
            style.margin.left       = 0;
            style.normal.textColor  = textColor;
            style.normal.background = File.GetAsset <Texture2D>(background);
            if (this.row.selected)
            {
                expand.normal.background = style.normal.background;
                expand.normal.textColor  = textColor;
                expand.hover             = expand.normal;
                style.hover = style.normal;
            }
            bool   open   = EditorPref.Get <bool>("StateWindow-GroupRow-" + row.section, false);
            string symbol = open ? "-" : "+";

            StateWindow.Clip(symbol, expand, -1, window.headerSize);
            if (GUILayoutUtility.GetLastRect().AddX(window.scroll.x).Clicked())
            {
                EditorPref.Toggle("StateWindow-GroupRow-" + row.section);
                foreach (var groupRow in this.groupRows)
                {
                    groupRow.disabled = !groupRow.disabled;
                }
                Event.current.Use();
                window.tableGUI.ShowAll();
                window.Repaint();
            }
            StateWindow.Clip(name, style, -1, window.headerSize);
        }
Ejemplo n.º 12
0
        public bool DrawTitle(string title, bool current)
        {
            EditorGUI.BeginChangeCheck();
            string skinSuffix = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false) ? "Dark" : "Light";

            skinSuffix += current ? "Open" : "";
            GUIStyle styleTitle = this.UI.GetStyle("Title" + skinSuffix);
            string   arrow      = "<color=#008ffeFF>▼</color>";
            string   state      = current ? arrow : "▶";
            bool     pressed    = GUILayout.Button(state + " " + title, styleTitle) ? !current : current;

            this.titleChanged = EditorGUI.EndChangeCheck() ? title : this.titleChanged;
            return(pressed);
        }
Ejemplo n.º 13
0
 public void Setup()
 {
     if (this.properties.Count > 0 && !this.setup)
     {
         foreach (var property in this.properties)
         {
             string path = "MonoBehaviourEditor-PropertyHide-" + this.target.GetInstanceID() + "-" + property.propertyPath;
             if (EditorPref.Get <bool>(path, false))
             {
                 this.hidden.Add(property);
             }
         }
         this.setup = true;
     }
 }
Ejemplo n.º 14
0
        public bool DrawToggleButton(string label, bool state)
        {
            string skinSuffix = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false) ? "Dark" : "Light";
            string prefix     = state ? "☗ " : "☖ ";

            skinSuffix += state ? "Active" : "";
            GUIStyle buttonStyle = this.UI.GetStyle("Button" + skinSuffix);

            if (GUILayout.Button(prefix + label, buttonStyle))
            {
                this.stateChanged = "ToggleButton-" + label;
                return(!state);
            }
            return(state);
        }
Ejemplo n.º 15
0
        public virtual void DrawStyle(int state = 0)
        {
            var      window   = StateWindow.Get();
            string   value    = "";
            var      stateRow = (StateRow)this.row.target;
            var      row      = this.row.target.As <StateRow>();
            int      rowIndex = window.rowIndex[row];
            var      mode     = (HeaderMode)EditorPref.Get <int>("StateWindow-Mode", 3);
            GUIStyle style    = new GUIStyle(GUI.skin.button);

            value = stateRow.requirements.Length > 1 ? (rowIndex + 1).ToString() : "";
            if (this.row.selected)
            {
                style = Style.Get("buttonSelected", true);
            }
            else if (state == -1)
            {
                style = Style.Get("buttonDisabled", true);
            }
            else if (state == 1)
            {
                style = Style.Get("buttonOn", true);
            }
            else if (state == 2)
            {
                style = Style.Get("buttonOff", true);
            }
            else if (state == 3)
            {
                style = Style.Get("buttonUsed", true);
            }
            style.fixedWidth = window.cellSize;
            if (mode == HeaderMode.HorizontalFit)
            {
                bool lastEnabled = this.row.fields.Last(x => !x.disabled) == this;
                style.margin.right = lastEnabled ? 18 : 0;
                style.fixedWidth   = lastEnabled ? 0 : style.fixedWidth;
            }
            float headerSize = window.headerSize;

            StateWindow.Clip(value.ToLabel(), style, GUI.skin.label.fixedWidth + 7, headerSize);
            if (!Proxy.IsPlaying() && GUILayoutUtility.GetLastRect().Hovered())
            {
                window.row     = this.row.order;
                window.column  = this.order;
                window.hovered = true;
            }
        }
Ejemplo n.º 16
0
        public virtual void DrawGroup(GUIContent label, bool drawAdvanced = true)
        {
            Rect labelRect = this.labelRect.AddX(12);

            EditorGUIUtility.AddCursorRect(this.fullRect, MouseCursor.ArrowPlus);
            bool formulaExpanded = EditorPref.Get <bool>(this.attribute.info.fullPath + "FormulaExpanded");

            if (this.labelRect.AddX(16).Clicked(0) || this.valueRect.Clicked(0))
            {
                this.dirty      = true;
                formulaExpanded = !formulaExpanded;
            }
            formulaExpanded = EditorGUI.Foldout(labelRect, formulaExpanded, label, this.skin.GetStyle("IconFormula"));
            EditorPref.Set <bool>(this.attribute.info.fullPath + "FormulaExpanded", formulaExpanded);
            if (formulaExpanded)
            {
                float lineHeight = EditorGUIUtility.singleLineHeight + 2;
                this.SetupAreas(this.fullRect.SetX(45).AddWidth(-55));
                for (int index = 0; index < this.attribute.data.Length; ++index)
                {
                    AttributeData currentData = this.attribute.data[index];
                    if (currentData == null)
                    {
                        continue;
                    }
                    this.DrawGroupRow(currentData, index, drawAdvanced);
                }
                this.SetupAreas(this.fullRect.AddY(lineHeight));
                this.drawer.overallHeight += lineHeight;
                if (GUI.Button(this.labelRect.SetWidth(100), "Add Attribute"))
                {
                    if (this.attribute.GetFormulaTypes().Length > 1)
                    {
                        this.DrawAddMenu();
                        return;
                    }
                    this.attribute.Add <DataType>();
                    this.dirty = true;
                }
            }
            else
            {
                string message = "[expand for details]";
                message.ToLabel().DrawLabel(this.valueRect, this.skin.GetStyle("WarningLabel"));
            }
        }
Ejemplo n.º 17
0
        public void DrawMenu()
        {
            GenericMenu  menu              = new GenericMenu();
            MenuFunction toggleAdvanced    = () => EditorPref.Toggle("MonoBehaviourEditor-Advanced");
            MenuFunction toggleInternal    = () => EditorPref.Toggle("MonoBehaviourEditor-Internal");
            MenuFunction toggleDictionary  = () => EditorPref.Toggle("MonoBehaviourEditor-Dictionary");
            MenuFunction hideAllDefaults   = () => EditorPref.Toggle("MonoBehaviourEditor-HideAllDefault");
            MenuFunction hideLocalDefaults = () => {
                this.hideDefault = !this.hideDefault;
                EditorPref.Set <bool>("MonoBehaviourEditor-" + this.target.GetInstanceID() + "HideDefault", this.hideDefault);
            };

            menu.AddItem(new GUIContent("Advanced"), EditorPref.Get <bool>("MonoBehaviourEditor-Advanced"), toggleAdvanced);
            menu.AddItem(new GUIContent("Internal"), EditorPref.Get <bool>("MonoBehaviourEditor-Internal"), toggleInternal);
            menu.AddItem(new GUIContent("Dictionary"), EditorPref.Get <bool>("MonoBehaviourEditor-Dictionary"), toggleDictionary);
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Defaults/Hide All"), EditorPref.Get <bool>("MonoBehaviourEditor-HideAllDefault"), hideAllDefaults);
            menu.AddItem(new GUIContent("Defaults/Hide Local"), this.hideDefault, hideLocalDefaults);
            if (this.hidden.Count > 0)
            {
                MenuFunction unhideAll = () => {
                    foreach (var property in this.hidden)
                    {
                        string path = "MonoBehaviourEditor-PropertyHide-" + this.target.GetInstanceID() + "-" + property.propertyPath;
                        EditorPref.Set <bool>(path, false);
                    }
                    this.hidden.Clear();
                };
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Unhide/All"), false, unhideAll);
                foreach (var property in this.hidden)
                {
                    SerializedProperty target = property;
                    MenuFunction       unhide = () => {
                        string path = "MonoBehaviourEditor-PropertyHide-" + this.target.GetInstanceID() + "-" + property.propertyPath;
                        EditorPref.Set <bool>(path, false);
                        this.hidden.Remove(target);
                    };
                    menu.AddItem(new GUIContent("Unhide/" + property.displayName), false, unhide);
                }
            }
            menu.ShowAsContext();
            Event.current.Use();
        }
Ejemplo n.º 18
0
        public void OnGUI()
        {
            Theme.disabled = EditorPref.Get <bool>("Zios.Theme.Options.Disabled", false);
            if (ThemeWindow.Inactive())
            {
                return;
            }
            Theme.Update();
            if (ThemeWindow.Inactive())
            {
                return;
            }
            ThemeContent.Monitor();
            var validTheme   = !Theme.active.IsNull() && Theme.active.name != "Default";
            var mouseChanged = this.lastMouse != Event.current.mousePosition;

            Call.Delay(RelativeColor.UpdateSystem, 0.2f, false);
            if (validTheme && mouseChanged)
            {
                this.lastMouse = Event.current.mousePosition;
                float delay = 0;
                if (Theme.hoverResponse == HoverResponse.None)
                {
                    return;
                }
                if (Theme.hoverResponse == HoverResponse.Slow)
                {
                    delay = 0.2f;
                }
                if (Theme.hoverResponse == HoverResponse.Moderate)
                {
                    delay = 0.05f;
                }
                Call.Delay("Redraw", () => {
                    Theme.UpdateColors();
                    var view = Reflection.GetUnityType("GUIView").GetVariable("mouseOverView");
                    if (!view.IsNull())
                    {
                        view.CallMethod("Repaint");
                    }
                }, delay, false);
            }
        }
Ejemplo n.º 19
0
        public void DrawViewMode()
        {
            var term = "Default";

            this.viewMode = EditorPref.Get <int>("GUISkin-Mode", 0);
            if (this.viewMode == 1)
            {
                term = "Replica";
            }
            if (this.viewMode == 2)
            {
                term = "Compact";
            }
            if (term.ToLabel().Layout(0, 30).DrawButton())
            {
                this.viewMode = (this.viewMode + 1) % 3;
                EditorPref.Set <int>("GUISkin-Mode", this.viewMode);
                EditorUI.foldoutChanged = true;
            }
        }
Ejemplo n.º 20
0
        public void CheckChanges()
        {
            if (Proxy.IsRepainting())
            {
                bool    fastInspector = EditorPref.Get <bool>("MonoBehaviourEditor-FastInspector");
                Vector2 mousePosition = Event.current.mousePosition;
                this.showAll = Event.current.alt && this.area.Contains(mousePosition);
                if (this.dirtyEvent != null)
                {
                    this.dirtyEvent();
                    this.dirtyEvent = null;
                }
                bool needsRepaint = false;
                if (fastInspector)
                {
                    foreach (var property in this.properties)
                    {
                        if (this.propertyArea.ContainsKey(property))
                        {
                            bool valid = this.propertyArea[property].InInspectorWindow();
                            if (valid != this.propertyVisible.AddNew(property))
                            {
                                this.propertyVisible[property] = valid;
                                needsRepaint = true;
                            }
                        }
                    }

                    /*if(!this.area.IsEmpty() && !this.area.InInspectorWindow()){
                     *      MonoBehaviourEditor.offScreen[this] = true;
                     * }*/
                }
                if (this.showAll || needsRepaint)
                {
                    this.Repaint();
                }
            }
        }
Ejemplo n.º 21
0
        public override void Draw()
        {
            var window = StateWindow.Get();
            var hidden = !this.target.Equals("") && !window.target.manual && this.target.As <StateRequirement>().name == "@External";

            if (hidden)
            {
                return;
            }
            var target = this.target is StateRequirement?this.target.As <StateRequirement>() : null;

            var      script     = !target.IsNull() ? target.target.As <StateBehaviour>() : null;
            var      scroll     = window.scroll;
            var      label      = this.target is string?new GUIContent("") : new GUIContent(this.target.GetVariable <string>("name"));
            GUIStyle style      = new GUIStyle(GUI.skin.label);
            var      mode       = (HeaderMode)EditorPref.Get <int>("StateWindow-Mode", 2);
            bool     darkSkin   = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false);
            Color    textColor  = Colors.Get("Gray");
            string   background = darkSkin ? "BoxBlackAWarm30" : "BoxWhiteBWarm50";

            if (window.target.external)
            {
                textColor  = darkSkin ? Colors.Get("Silver") : Colors.Get("Black");
                background = darkSkin ? "BoxBlackA30" : "BoxWhiteBWarm";
            }
            if (label.text == "")
            {
                this.disabled           = this.row.fields.Skip(1).Count(x => !x.disabled) < 1;
                window.headerSize       = 64;
                style.margin.left       = 5;
                style.hover             = style.normal;
                style.normal.background = File.GetAsset <Texture2D>(background);
                if (mode == HeaderMode.Vertical)
                {
                    window.headerSize = 35;
                    style.fixedHeight = style.fixedWidth;
                    StateWindow.Clip(label, style, 0, window.headerSize);
                }
                if (mode != HeaderMode.Vertical)
                {
                    StateWindow.Clip(label, style, -1, -1);
                }
                return;
            }
            bool fieldHovered = window.column == this.order;

            if (fieldHovered)
            {
                background = darkSkin ? "BoxBlackHighlightBlueAWarm" : "BoxBlackHighlightBlueDWarm";
                textColor  = darkSkin ? Colors.Get("ZestyBlue") : Colors.Get("White");
            }
            if (Proxy.IsPlaying() && !script.IsNull())
            {
                textColor  = Colors.Get("Gray");
                background = darkSkin ? "BoxBlackAWarm30" : "BoxWhiteBWarm50";
                bool usable = target.name == "@External" ? window.target.external : script.usable;
                bool active = target.name == "@External" ? window.target.external : script.active;
                if (usable)
                {
                    textColor  = darkSkin ? Colors.Get("Silver") : Colors.Get("Black");
                    background = darkSkin ? "BoxBlackA30" : "BoxWhiteBWarm";
                }
                if (script.used)
                {
                    textColor  = darkSkin ? Colors.Get("White") : Colors.Get("White");
                    background = darkSkin ? "BoxBlackHighlightYellowAWarm" : "BoxBlackHighlightYellowDWarm";
                }
                if (active)
                {
                    textColor  = darkSkin ? Colors.Get("White") : Colors.Get("White");
                    background = darkSkin ? "BoxBlackHighlightPurpleAWarm" : "BoxBlackHighlightPurpleDWarm";
                }
            }
            style.normal.textColor  = textColor;
            style.normal.background = File.GetAsset <Texture2D>(background);
            if (mode == HeaderMode.Vertical)
            {
                window.cellSize = style.fixedHeight;
                float    halfWidth  = style.fixedWidth / 2;
                float    halfHeight = style.fixedHeight / 2;
                GUIStyle rotated    = new GUIStyle(style).Rotate90();
                Rect     last       = GUILayoutUtility.GetRect(new GUIContent(""), rotated);
                GUIUtility.RotateAroundPivot(90, last.center);
                Rect position = new Rect(last.x, last.y, 0, 0);
                position.x         += halfHeight - halfWidth;
                position.y         += -halfHeight + halfWidth;
                style.overflow.left = (int)-scroll.y;
                label.text          = style.overflow.left >= -(position.width / 4) - 9 ? label.text : "";
                label.ToLabel().DrawLabel(position, style);
                GUI.matrix = Matrix4x4.identity;
            }
            else
            {
                style.fixedWidth -= 36;
                window.cellSize   = style.fixedWidth;
                if (mode == HeaderMode.HorizontalFit)
                {
                    var   visible = this.row.fields.Skip(1).Where(x => !x.disabled).ToList();
                    float area    = window.cellSize = (Screen.width - style.fixedWidth - 56) / visible.Count;
                    area = window.cellSize = Mathf.Floor(area - 2);
                    bool lastEnabled = visible.Last() == this;
                    style.margin.right = lastEnabled ? 18 : 0;
                    style.fixedWidth   = lastEnabled ? 0 : area;
                }
                style.alignment = TextAnchor.MiddleCenter;
                StateWindow.Clip(label, style, GUI.skin.label.fixedWidth + 7, -1);
            }
            this.CheckClicked(0, scroll.y);
        }
Ejemplo n.º 22
0
        public override void OnGUI(Rect area, SerializedProperty property, GUIContent label)
        {
            EditorUI.Reset();
            if (!Attribute.ready)
            {
                EditorGUI.ProgressBar(area, AttributeManager.percentLoaded, "Updating");
                return;
            }
            string skin = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false) ? "Dark" : "Light";

            GUI.skin = File.GetAsset <GUISkin>("Gentleface-" + skin + ".guiskin");
            Rect        labelRect   = area.SetWidth(EditorGUIUtility.labelWidth);
            Rect        valueRect   = area.Add(labelRect.width, 0, -labelRect.width, 0);
            EventTarget eventTarget = property.GetObject <EventTarget>();
            string      eventName   = eventTarget.name;
            GameObject  target      = eventTarget.target.Get();

            label.ToLabel().DrawLabel(labelRect, null, true);
            if (target.IsNull())
            {
                this.targeted = false;
            }
            string targetLabel = this.targeted ? "+" : "-";
            string manualLabel = this.manual ? "M" : "S";
            var    buttonArea  = valueRect.SetWidth(16);

            if (targetLabel.ToLabel().DrawButton(buttonArea))
            {
                this.targeted = !this.targeted;
            }
            if (manualLabel.ToLabel().DrawButton(buttonArea.AddX(18)))
            {
                this.manual = !this.manual;
            }
            valueRect = valueRect.Add(36, 0, -36, 0);
            if (!this.targeted)
            {
                property.FindPropertyRelative("target").Draw(valueRect);
                return;
            }
            if (!this.manual)
            {
                string eventType = eventTarget.mode == EventMode.Listeners ? "Listen" : "Caller";
                bool   hasEvents = eventType == "Listen" ? Events.HasListeners(target) : Events.HasCallers(target);
                if (!hasEvents)
                {
                    string error = "";
                    if (!target.IsNull())
                    {
                        error = "No <b>" + eventType + "</b> events found for target -- " + target.name;
                    }
                    if (target.IsNull())
                    {
                        error = "No global <b>" + eventType + "</b> events exist.";
                    }
                    error.ToLabel().DrawLabel(valueRect, GUI.skin.GetStyle("WarningLabel"));
                    return;
                }
                List <string> events = eventType == "Listen" ? Events.GetEventNames("Listen", target) : Events.GetEventNames("Caller", target);
                events.Sort();
                events = events.OrderBy(item => item.Contains("/")).ToList();
                events.RemoveAll(item => item.StartsWith("@"));
                int  index   = eventName.IsEmpty() ? 0 : events.IndexOf(eventName);
                bool missing = index == -1;
                if (index == -1)
                {
                    events.Insert(0, "[Missing] " + eventName);
                    index = 0;
                }
                index = events.Draw(valueRect, index);
                if (!missing || index != 0)
                {
                    eventTarget.name.Set(events[index]);
                }
                return;
            }
            string name = eventTarget.name.Get().Draw(valueRect);

            eventTarget.name.Set(name);
            if (GUI.changed)
            {
                property.serializedObject.targetObject.DelayEvent("On Validate", 1);
            }
        }
Ejemplo n.º 23
0
        public virtual void DrawStyle()
        {
            var      window      = StateWindow.Get();
            var      stateRow    = (StateRow)this.row.target;
            var      row         = this.row.target.As <StateRow>();
            var      script      = row.target;
            bool     darkSkin    = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false);
            string   name        = this.target is string?(string)this.target : this.target.As <StateRow>().name;
            string   background  = darkSkin ? "BoxBlackA30" : "BoxWhiteBWarm";
            Color    textColor   = darkSkin ? Colors.Get("Silver") : Colors.Get("Black");
            string   prefixColor = Colors.Get("DarkOrange").ToHex();
            GUIStyle style       = new GUIStyle(GUI.skin.label);

            style.margin.left = 5;
            bool fieldHovered = window.row == this.row.order || this.hovered;

            if (fieldHovered)
            {
                prefixColor = Colors.Get("ZestyOrange").ToHex();
                textColor   = darkSkin ? Colors.Get("ZestyBlue") : Colors.Get("White");
                background  = darkSkin ? "BoxBlackHighlightBlueAWarm" : "BoxBlackHighlightBlueDWarm";
            }
            if (this.row.selected)
            {
                prefixColor = Colors.Get("ZestyOrange").ToHex();
                textColor   = darkSkin ? Colors.Get("White") : Colors.Get("White");
                background  = darkSkin ? "BoxBlackHighlightCyanA" : "BoxBlackHighlightCyanCWarm";
            }
            if (Proxy.IsPlaying())
            {
                textColor  = Colors.Get("Gray");
                background = darkSkin ? "BoxBlackAWarm30" : "BoxWhiteBWarm50";
                bool usable = row.target is StateTable && row.target != window.target ? row.target.As <StateTable>().external : script.usable;
                if (usable)
                {
                    textColor  = darkSkin ? Colors.Get("Silver") : Colors.Get("Black");
                    background = darkSkin ? "BoxBlackA30" : "BoxWhiteBWarm";
                }
                if (script.used)
                {
                    textColor  = darkSkin ? Colors.Get("White") : Colors.Get("White");
                    background = darkSkin ? "BoxBlackHighlightYellowAWarm" : "BoxBlackHighlightYellowDWarm";
                }
                if (script.active)
                {
                    textColor  = darkSkin ? Colors.Get("White") : Colors.Get("White");
                    background = darkSkin ? "BoxBlackHighlightPurpleAWarm" : "BoxBlackHighlightPurpleDWarm";
                }
            }
            if (!row.section.IsEmpty())
            {
                style.margin.left = 33;
                style.fixedWidth -= 28;
            }
            style.normal.textColor  = textColor;
            style.normal.background = File.GetAsset <Texture2D>(background);
            if (this.row.selected)
            {
                style.hover = style.normal;
            }
            int        currentRow = window.rowIndex[stateRow] + 1;
            int        totalRows  = stateRow.requirements.Length;
            var        prefix     = stateRow.requirements.Length > 1 ? "<color=" + prefixColor + "><i>[" + currentRow + "/" + totalRows + "]</i></color>  " : "";
            GUIContent content    = new GUIContent(prefix + name);

            StateWindow.Clip(content, style, -1, window.headerSize);
        }
Ejemplo n.º 24
0
        public static void Draw(Rect area, Target target, GUIContent label)
        {
            if (target.parent.IsNull())
            {
                return;
            }
            if (TargetDrawer.skin.IsNull())
            {
                string skin = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false) ? "Dark" : "Light";
                TargetDrawer.skin = File.GetAsset <GUISkin>("Gentleface-" + skin + ".guiskin");
            }
            Rect  toggleRect   = new Rect(area);
            Rect  propertyRect = new Rect(area);
            float labelWidth   = label.text.IsEmpty() ? 0 : EditorGUIUtility.labelWidth;

            propertyRect.x     += labelWidth + 18;
            propertyRect.width -= labelWidth + 18;
            toggleRect.x       += labelWidth;
            toggleRect.width    = 18;
            bool previousMode = target.mode == TargetMode.Direct;
            bool currentMode  = previousMode.Draw(toggleRect, "", TargetDrawer.skin.GetStyle("TargetToggle"));

            if (previousMode != currentMode)
            {
                target.mode = target.mode == TargetMode.Direct ? TargetMode.Search : TargetMode.Direct;
            }
            label.ToLabel().DrawLabel(area, null, true);
            ProxyEditor.RecordObject(target.parent, "Target Changes");
            if (target.mode == TargetMode.Direct)
            {
                target.directObject = target.directObject.Draw <GameObject>(propertyRect, "", true);
            }
            else
            {
                target.Verify();
                var     faded       = GUI.skin.textField.Background("").TextColor(GUI.skin.textField.normal.textColor.SetAlpha(0.75f)).ContentOffset(-3, 0).UseState("normal");
                Rect    textRect    = propertyRect;
                string  result      = !target.searchObject.IsNull() ? target.searchObject.GetPath().Trim("/") : "Not Found.";
                Vector2 textSize    = TargetDrawer.skin.textField.CalcSize(new GUIContent(target.search));
                Vector2 subtleSize  = faded.CalcSize(new GUIContent(result));
                float   subtleX     = propertyRect.x + propertyRect.width - subtleSize.x;
                float   subtleWidth = subtleSize.x;
                float   minimumX    = propertyRect.x + textSize.x + 3;
                if (subtleX < minimumX)
                {
                    subtleWidth -= (minimumX - subtleX);
                    subtleX      = minimumX;
                }
                propertyRect = propertyRect.SetX(subtleX).SetWidth(subtleWidth);
                EditorGUIUtility.AddCursorRect(propertyRect, MouseCursor.Zoom);
                if (!target.searchObject.IsNull() && propertyRect.Clicked(0))
                {
                    Selection.activeGameObject = target.searchObject;
                    Event.current.Use();
                }
                target.search = target.search.Draw(textRect);
                result.ToLabel().DrawLabel(propertyRect, faded);
            }
            if (GUI.changed && !target.IsNull())
            {
                target.Search();
                if (target.parent is DataBehaviour)
                {
                    var parent = target.parent.As <DataBehaviour>();
                    parent.DelayEvent(parent.path, "On Validate");
                    ProxyEditor.SetDirty(parent);
                }
            }
        }
Ejemplo n.º 25
0
 public virtual void DrawContext(AttributeData data, bool showRemove = false, bool isRoot = true)
 {
     if (this.labelRect.AddWidth(20).Clicked(1))
     {
         this.contextOpen = true;
         GenericMenu    menu            = new GenericMenu();
         AttributeMode  mode            = this.attribute.info.mode;
         AttributeUsage usage           = data.usage;
         bool           advanced        = EditorPref.Get <bool>(data.path + "Advanced");
         MenuFunction   toggleAdvanced  = () => { EditorPref.Set <bool>(data.path + "Advanced", !advanced); };
         MenuFunction   removeAttribute = () => { this.attribute.Remove(data); };
         MenuFunction   modeNormal      = () => { this.attribute.info.mode = AttributeMode.Normal; };
         MenuFunction   modeLinked      = () => { this.attribute.info.mode = AttributeMode.Linked; };
         MenuFunction   modeFormula     = () => { this.attribute.info.mode = AttributeMode.Formula; };
         MenuFunction   modeGroup       = () => { this.attribute.info.mode = AttributeMode.Group; };
         MenuFunction   usageDirect     = () => {
             data.usage         = AttributeUsage.Direct;
             data.referencePath = "";
             data.referenceID   = "";
             data.reference     = null;
         };
         MenuFunction usageShaped = () => { data.usage = AttributeUsage.Shaped; };
         MenuFunction fixType     = () => { this.SwapType(0, typeof(DataType), this.attribute.defaultSet); };
         bool         normal      = this.attribute.info.mode == AttributeMode.Normal;
         if (this.attribute.locked)
         {
             menu.AddDisabledItem(new GUIContent("Attribute Locked"));
             menu.ShowAsContext();
             return;
         }
         if (isRoot || mode.Matches("Normal", "Linked"))
         {
             if (mode.Matches("Normal", "Linked") && usage.Matches("Shaped") && this.attribute.canAdvanced)
             {
                 menu.AddItem(new GUIContent("Advanced"), advanced, toggleAdvanced);
                 menu.AddSeparator("/");
             }
             if (this.attribute.canDirect)
             {
                 menu.AddItem(new GUIContent("Direct"), normal && (usage == AttributeUsage.Direct), fixType + modeNormal + usageDirect);
             }
             if (this.attribute.canShape)
             {
                 menu.AddItem(new GUIContent("Shaped"), normal && (usage == AttributeUsage.Shaped), fixType + modeNormal + usageShaped);
             }
             if (this.attribute.canLink)
             {
                 menu.AddItem(new GUIContent("Linked"), (mode == AttributeMode.Linked), fixType + modeLinked + usageShaped);
             }
             menu.AddSeparator("/");
             if (this.attribute.canFormula)
             {
                 menu.AddItem(new GUIContent("Formula"), (mode == AttributeMode.Formula), modeFormula);
             }
             if (this.attribute.canGroup)
             {
                 menu.AddItem(new GUIContent("Group"), (mode == AttributeMode.Group), modeGroup);
             }
         }
         else if (mode.Matches("Formula"))
         {
             menu.AddItem(new GUIContent("Advanced"), advanced, toggleAdvanced);
             this.DrawTypeMenu(data, menu);
             menu.AddSeparator("/");
             if (this.attribute.canDirect)
             {
                 menu.AddItem(new GUIContent("Direct"), usage == AttributeUsage.Direct, usageDirect);
             }
             if (this.attribute.canShape)
             {
                 menu.AddItem(new GUIContent("Shaped"), usage == AttributeUsage.Shaped, usageShaped);
             }
         }
         if (showRemove)
         {
             if (!mode.Matches("Group"))
             {
                 menu.AddSeparator("/");
             }
             menu.AddItem(new GUIContent("Remove"), false, removeAttribute);
         }
         menu.ShowAsContext();
     }
     if (this.contextOpen && Event.current.button == 0)
     {
         this.dirty       = true;
         this.contextOpen = false;
     }
 }
Ejemplo n.º 26
0
        public virtual void BuildTable()
        {
            if (this.target.IsNull())
            {
                return;
            }
            StateTable stateTable = this.target;

            stateTable.UpdateTableList();
            StateRow[] activeTable = stateTable.tables[this.tableIndex];
            this.tableGUI = new Table();
            TableRow tableRow = this.tableGUI.AddRow();

            tableRow.AppendField(new TitleField(stateTable));
            if (activeTable.Length > 0)
            {
                tableRow = this.tableGUI.AddRow();
                tableRow.AppendField(new HeaderField(""));
                foreach (var stateRequirement in activeTable[0].requirements[0].data)
                {
                    var field = new HeaderField(stateRequirement);
                    field.disabled = !stateRequirement.target.IsEnabled();
                    tableRow.AppendField(field);
                }
                foreach (StateRow stateRow in activeTable)
                {
                    if (!this.rowIndex.ContainsKey(stateRow))
                    {
                        this.rowIndex[stateRow] = 0;
                    }
                    int rowIndex = this.rowIndex[stateRow];
                    tableRow          = this.tableGUI.AddRow(stateRow);
                    tableRow.disabled = !stateRow.target.IsEnabled();
                    tableRow.AppendField(new LabelField(stateRow));
                    foreach (StateRequirement requirement in stateRow.requirements[rowIndex].data)
                    {
                        var tableField = new StateField(requirement);
                        tableField.disabled = tableRow.disabled || !requirement.target.IsEnabled();
                        tableRow.AppendField(tableField);
                    }
                }
                this.setupSections.Clear();
                var tableRows = this.tableGUI.rows.Skip(2).ToList();
                foreach (TableRow row in tableRows)
                {
                    if (row.disabled)
                    {
                        continue;
                    }
                    var    stateRow = row.target.As <StateRow>();
                    string section  = stateRow.section;
                    if (!section.IsEmpty() && !this.setupSections.Contains(section))
                    {
                        bool open       = EditorPref.Get <bool>("StateWindow-GroupRow-" + section, false);
                        var  groupRow   = new TableRow(stateRow, this.tableGUI);
                        var  groupLabel = new GroupLabelField(section);
                        var  groupRows  = tableRows.Where(x => x.target.As <StateRow>().section == section).ToArray();
                        groupLabel.groupRows = groupRows;
                        groupRow.disabled    = groupLabel.groupRows.Count(x => !x.disabled) == 0;
                        groupRow.AppendField(groupLabel);
                        foreach (TableField field in row.fields)
                        {
                            var groupField   = new GroupField(field.target);
                            var columnFields = groupRows.SelectMany(x => x.fields).Where(x => x is StateField && x.order == field.order).Cast <StateField>().ToArray();
                            groupField.disabled     = groupRow.disabled || field.disabled;
                            groupField.columnFields = columnFields;
                            groupRow.AppendField(groupField);
                        }
                        foreach (var item in groupRows)
                        {
                            item.disabled = !open;
                        }
                        int insertIndex = tableRows.FindIndex(x => x.target == stateRow);
                        this.tableGUI.rows.Insert(insertIndex + 2, groupRow);
                        this.setupSections.Add(section);
                    }
                }
                var ordered = this.tableGUI.rows.Skip(2).Where(x => x.target is StateRow).OrderBy(x => {
                    var row = x.target.As <StateRow>();
                    if (!row.section.IsEmpty())
                    {
                        return(row.section);
                    }
                    return(row.name);
                });
                this.tableGUI.rows = this.tableGUI.rows.Take(2).Concat(ordered).ToList();
                this.tableGUI.Reorder();
            }
            this.Repaint();
        }
Ejemplo n.º 27
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");
            }
        }
Ejemplo n.º 28
0
        public GUISkin GetSkin()
        {
            string skin = EditorGUIUtility.isProSkin || EditorPref.Get <bool>("Zios.Theme.Dark", false) ? this.skinDark : this.skinLight;

            return(File.GetAsset <GUISkin>(skin + ".guiskin"));
        }
Ejemplo n.º 29
0
        public virtual void DrawShaped(Rect area, AttributeData data, GUIContent label, bool?drawSpecial = null, bool?drawOperator = null)
        {
            label.ToLabel().DrawLabel(this.labelRect);
            Rect toggleRect   = area.SetWidth(16);
            bool toggleActive = this.targetMode.ContainsKey(data) ? this.targetMode[data] : !data.referenceID.IsEmpty();

            this.targetMode[data] = toggleActive.Draw(toggleRect, "", this.skin.GetStyle("CheckmarkToggle"));
            if (!this.targetMode[data])
            {
                Rect targetRect = area.Add(18, 0, -18, 0);
                bool ticked     = GUI.changed;
                TargetDrawer.Draw(targetRect, data.target, new GUIContent(""));
                if (this.attribute is AttributeGameObject && !ticked && GUI.changed)
                {
                    data.referenceID   = "";
                    data.referencePath = "";
                    data.reference     = null;
                }
                return;
            }
            List <string> attributeNames = new List <string>();
            List <string> attributeIDs   = new List <string>();
            int           attributeIndex = -1;
            GameObject    targetScope    = data.target.Get();

            if (!targetScope.IsNull() && Attribute.lookup.ContainsKey(targetScope))
            {
                var lookup = Attribute.lookup[targetScope];
                foreach (var item in lookup)
                {
                    if (item.Value.data.Length < 1)
                    {
                        continue;
                    }
                    if (item.Value.info.type != data.GetType())
                    {
                        continue;
                    }
                    bool isSelf = (item.Value.info.id == this.attribute.info.id) || (item.Value.data[0].referenceID == this.attribute.info.id);
                    if (!isSelf)
                    {
                        attributeNames.Add(item.Value.info.path);
                    }
                }
                if (attributeNames.Count != this.attributeNames.AddNew(data).Count)
                {
                    this.attributeNames[data] = attributeNames.Order().OrderBy(item => item.Contains("/")).ToList();
                }
                foreach (string name in this.attributeNames[data])
                {
                    var attribute = lookup.Values.ToList().Find(x => x.info.path == name);
                    if (attribute != null)
                    {
                        attributeIDs.Add(attribute.info.id);
                    }
                }
                if (!data.referenceID.IsEmpty())
                {
                    attributeIndex = attributeIDs.IndexOf(data.referenceID);
                }
            }
            else
            {
                this.attributeNames.Clear();
            }
            if (this.attributeNames.Count > 0)
            {
                Rect line        = area;
                bool showSpecial = drawSpecial != null && (EditorPref.Get <bool>(data.path + "Advanced") || data.special != 0);
                if (attributeIndex == -1)
                {
                    string message = data.referenceID.IsEmpty() ? "[Not Set]" : "[Missing] " + data.referencePath;
                    attributeIndex = 0;
                    this.attributeNames[data].Insert(0, message);
                    attributeIDs.Insert(0, "0");
                }
                if (drawOperator != null)
                {
                    this.DrawOperator(line, data, (bool)!drawOperator);
                    line = line.Add(51, 0, -51, 0);
                }
                if (showSpecial)
                {
                    this.DrawSpecial(line, data);
                    line = line.Add(51, 0, -51, 0);
                }
                Rect attributeRect = line.Add(18, 0, -18, 0);
                int  previousIndex = attributeIndex;
                attributeIndex = this.attributeNames[data].Draw(attributeRect, attributeIndex);
                string name = this.attributeNames[data][attributeIndex];
                string id   = attributeIDs[attributeIndex];
                if (attributeIndex != previousIndex)
                {
                    data.referencePath = name;
                    data.referenceID   = id;
                    data.reference     = Attribute.lookup[targetScope][data.referenceID];
                }
            }
            else
            {
                Rect   warningRect = area.Add(18, 0, -18, 0);
                string targetName  = targetScope.IsNull() ? "Target" : targetScope.ToString().Remove("(UnityEngine.GameObject)").Trim();
                string typeName    = data.GetType().Name.Trim("Attribute", "Data");
                string message     = "<b>" + targetName.Truncate(24) + "</b> has no <b>" + typeName + "</b> attributes.";
                message.ToLabel().DrawLabel(warningRect, this.skin.GetStyle("WarningLabel"));
            }
        }