Beispiel #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;
            }
        }
Beispiel #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;
            }
        }
Beispiel #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();
                }
            }
        }
Beispiel #4
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);
        }
        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;
            }
        }
 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));
        }
Beispiel #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);
        }
Beispiel #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;
     }
 }
        /// <summary>
        /// Draw an option for a player pref
        /// </summary>
        private static void PrefOptionGUI(string label, EditorPref <bool> pref, string tooltip)
        {
            bool initial = pref.Value;

            pref.Value = EditorGUILayout.Toggle(new GUIContent(label, tooltip), pref.Value);

            // check if value changed
            if (initial != pref.Value)
            {
                SavePref(pref);
            }
        }
Beispiel #11
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;
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }
Beispiel #14
0
        public void Export(string path = null)
        {
            var theme      = Theme.active;
            var targetPath = path ?? Theme.storagePath;
            var targetName = theme.name + "-Variant";

            path = path.IsEmpty() ? EditorUtility.SaveFilePanel("Save Theme", targetPath, targetName, "unitytheme") : path;
            if (path.Length > 0)
            {
                var file = File.Create(path);
                file.Write(this.Serialize());
                EditorPref.Set <string>("Zios.Theme" + Theme.suffix, theme.name);
                Theme.needsSetup = true;
            }
        }
Beispiel #15
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);
        }
 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;
     }
 }
Beispiel #17
0
        public static void Draw(this GUIStyle current, string key, bool compact = false, bool grouped = false, bool headers = false)
        {
            EditorGUILayout.BeginVertical();
            var styleKey     = key + "." + current.name;
            var styleFoldout = current.name.ToLabel().DrawFoldout(styleKey);

            if (styleFoldout)
            {
                var labelWidth = compact ? 140 : 0;
                EditorGUI.indentLevel += 1;
                EditorUI.SetFieldSize(-1, labelWidth, false);
                current.name = current.name.Draw("Name".ToLabel());
                EditorPref.Set <bool>(key + "." + current.name, true);
                if (compact && headers)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(140);
                    EditorUI.SetLayout(120);
                    "Text".ToLabel().DrawLabel(EditorStyles.boldLabel, false);
                    "Background".ToLabel().DrawLabel(EditorStyles.boldLabel, false);
                    EditorGUILayout.EndHorizontal();
                }
                foreach (var state in current.GetNamedStates())
                {
                    state.Value.Draw(state.Key, compact, styleKey + "." + state.Key);
                }
                current.border.Draw("Border", compact, key + ".Border");
                current.margin.Draw("Margin", compact, key + ".Margin");
                current.padding.Draw("Padding", compact, key + ".Padding");
                current.overflow.Draw("Overflow", compact, key + ".Overflow");
                if (!grouped || "Text".ToTitleCase().ToLabel().DrawFoldout(key + "Text"))
                {
                    current.DrawTextSettings(compact);
                }
                if (!grouped || "Position & Size".ToTitleCase().ToLabel().DrawFoldout(key + "Area"))
                {
                    current.imagePosition = current.imagePosition.Draw("Image Position").As <ImagePosition>();
                    current.contentOffset = current.contentOffset.DrawVector2("Content Offset");
                    current.fixedWidth    = current.fixedWidth.Draw("Fixed Width");
                    current.fixedHeight   = current.fixedHeight.Draw("Fixed Height");
                    current.stretchWidth  = current.stretchWidth.Draw("Stretch Width");
                    current.stretchHeight = current.stretchHeight.Draw("Stretch Height");
                }
                EditorUI.ResetFieldSize();
                EditorGUI.indentLevel -= 1;
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #18
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;
            }
        }
Beispiel #19
0
        public void Export(string path = null)
        {
            var theme    = Theme.active;
            var savePath = path ?? Theme.storagePath + "Fontsets";
            var saveName = theme.fontset.name + "-Variant";

            path = path.IsEmpty() ? ProxyEditor.SaveFilePanel("Save Theme [Fonts]", savePath.GetAssetPath(), saveName, "unityfontset") : path;
            if (path.Length > 0)
            {
                var file = File.Create(path);
                file.Write(this.Serialize());
                ProxyEditor.ImportAsset(path.GetAssetPath());
                EditorPref.Set <string>("Zios.Theme.Fontset" + Theme.suffix, path.GetFileName());
                Theme.Reset();
            }
        }
Beispiel #20
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"));
            }
        }
Beispiel #21
0
        public bool DrawInputMode(string fallback = "Search", string splitBy = " ", string endSymbol = "+")
        {
            EditorGUILayout.BeginHorizontal();
            var color       = EditorStyles.textField.normal.textColor.SetAlpha(0.5f);
            var baseStyle   = EditorStyles.textField.Alignment("MiddleCenter");
            var symbolStyle = baseStyle.FixedWidth(24).FontSize(16).TextColor(color);
            var inputStyle  = baseStyle.FontStyle("BoldAndItalic");

            EditorUI.SetLayout(-1, 30);
            if ("*".ToLabel().DrawButton(symbolStyle.ContentOffset(1, 0).Overflow(0, 3, 0, 0), false))
            {
                var    menu  = new EditorMenu();
                Action clear = () => this.queue = "";
                menu.Add("Search", this.inputMode == 0, (() => { this.inputMode = 0; }) + clear);
                //menu.Add("Split",this.inputMode==1,(()=>{this.inputMode=1;})+clear);
                menu.Draw();
            }
            var filter       = this.inputTerms.Join(splitBy).Replace("~", " ").Draw(null, inputStyle);
            var inputChanged = EditorUI.lastChanged;

            EditorUI.lastChanged = false;
            endSymbol.ToLabel().DrawButton(symbolStyle.ContentOffset(-2, 0).Overflow(3, 0, 0, 0), false);
            EditorUI.SetLayout(-1, 0);
            EditorGUILayout.EndHorizontal();
            bool open   = false;
            var  output = new StringBuilder();

            foreach (var symbol in filter)
            {
                if (symbol == '[')
                {
                    open = true;
                }
                if (symbol == ']')
                {
                    open = false;
                }
                output.Append(symbol == ' ' && open ? '~' : symbol);
            }
            this.queue      = this.queue ?? (output.ToString().Trim().IsEmpty() ? fallback : output.ToString());
            this.queueSplit = splitBy;
            EditorPref.Set <string>("GUISkin-" + fallback + "-" + this.hash, this.inputTerms.Join(splitBy));
            GUI.changed = false;
            return(inputChanged);
        }
        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();
        }
Beispiel #23
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);
            }
        }
Beispiel #24
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;
            }
        }
        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();
                }
            }
        }
Beispiel #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();
        }
Beispiel #27
0
        public static void Handle(string data)
        {
            var items = data.Split("&&&");

            Reflection.ResetCache();
            foreach (var change in items)
            {
                if (change.Trim().IsEmpty())
                {
                    continue;
                }
                if (change.Contains("###"))
                {
                    var path  = change.Split("###")[0];
                    var field = change.Split("###")[1].Split("|||")[0];
                    var value = change.Split("###")[1].Split("|||")[1];
                    var scope = Reflection.GetType(path);
                    var type  = scope.GetVariableType(field);
                    if (type == typeof(string))
                    {
                        scope.SetVariable(field, value);
                    }
                    else if (type == typeof(int))
                    {
                        scope.SetVariable(field, value.ToInt());
                    }
                    else if (type == typeof(float))
                    {
                        scope.SetVariable(field, value.ToFloat());
                    }
                    else if (type == typeof(bool))
                    {
                        scope.SetVariable(field, value.ToBool());
                    }
                    else if (type.IsEnum)
                    {
                        scope.SetVariable(field, Enum.Parse(type, value));
                    }
                    Undo.snapshot.Remove(scope);
                }
                else
                {
                    var key   = change.Split("|||")[0];
                    var type  = change.Split("|||")[1].Split("---")[0];
                    var value = change.Split("|||")[1].Split("---")[1];
                    if (type.Contains("Bool"))
                    {
                        EditorPref.Set <bool>(key, value.ToBool());
                    }
                    else if (type.Contains("Int"))
                    {
                        EditorPref.Set <int>(key, value.ToInt());
                    }
                    else if (type.Contains("String"))
                    {
                        EditorPref.Set <string>(key, value);
                    }
                    else if (type.Contains("Float"))
                    {
                        EditorPref.Set <float>(key, value.ToFloat());
                    }
                }
            }
            Undo.snapshotPrefs.Clear();
        }
 /// <summary>
 /// Save a bool pref to EditorPrefs
 /// </summary>
 private static void SavePref(EditorPref <bool> pref)
 {
     EditorPrefs.SetBool(pref.Key, pref.Value);
 }
Beispiel #29
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);
                }
            }
        }
        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");
            }
        }