Ejemplo n.º 1
0
        private void DrawSettingsInspectors()
        {
            using (var scroll = new EditorGUILayout.ScrollViewScope(_scroll))
            {
                _scroll = scroll.scrollPosition;

                for (var i = 0; i < _settings.Length; i++)
                {
                    var settings = _settings[i];

                    settings.Foldout = EditorGUILayout.Foldout(settings.Foldout, settings.Name);

                    if (settings.Foldout)
                    {
                        settings.DrawInspector();
                    }

                    MyGUI.DrawLine(MyGUI.Gray, true);
                }
            }
        }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            if (_titleStyle == null)
            {
                _titleStyle           = new GUIStyle(EditorStyles.boldLabel);
                _titleStyle.fontSize  = 42;
                _titleStyle.fontStyle = FontStyle.BoldAndItalic;
                _titleStyle.alignment = TextAnchor.MiddleCenter;
            }

            if (_buttonStyle == null)
            {
                _buttonStyle = new GUIStyle(MyGUI.HelpBoxStyle);
                _buttonStyle.hover.textColor = MyGUI.Colors.Blue;
            }

            var buttonWidth  = GUILayout.Width(120);
            var buttonHeight = GUILayout.Height(30);
            var leftOffset   = 20;


            wantsMouseMove = true;
            if (Event.current.type == EventType.MouseMove)
            {
                Repaint();
            }


            //buttonStyle.hover.background = buttonStyle.active.background.WithSolidColor(Color.red);

            EditorGUILayout.Space();


            EditorGUILayout.LabelField("MyBox", _titleStyle, GUILayout.Height(60));

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("  Github Page ↗", _buttonStyle, buttonWidth, buttonHeight))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox");
                }

                if (GUILayout.Button("  Attributes ↗", _buttonStyle, buttonWidth, buttonHeight))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/wiki/Attributes");
                }

                if (GUILayout.Button("  Extensions ↗", _buttonStyle, buttonWidth, buttonHeight))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/tree/master/Extensions");
                }

                if (GUILayout.Button("  Tools, Features ↗", _buttonStyle, buttonWidth, buttonHeight))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/wiki/Tools-and-Features");
                }

                GUILayout.FlexibleSpace();
            }

            MyGUI.DrawLine(Color.white, true);

            EditorGUILayout.LabelField("MyBox Settings", new GUIStyle(EditorStyles.centeredGreyMiniLabel));

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                using (new EditorGUILayout.VerticalScope())
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.Space(leftOffset);
                        MyBoxSettings.CheckForUpdates = EditorGUILayout.Toggle("Check for Updates: ", MyBoxSettings.CheckForUpdates);
                        GUILayout.FlexibleSpace();
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        var label = new GUIContent("AutoSave on Play: ", "Save changes in opened scenes before Playmode. " +
                                                   "\nUnity crasher from time to time you know...");
                        EditorGUILayout.Space(leftOffset);
                        MyBoxSettings.AutoSaveEnabled = EditorGUILayout.Toggle(label, MyBoxSettings.AutoSaveEnabled);
                        GUILayout.FlexibleSpace();
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        var label = new GUIContent("Clean Empty Folders: ", "Delete empty folders in project on Save. " +
                                                   "\nIt handles VCS issue with .meta files for empty folders");
                        EditorGUILayout.Space(leftOffset);
                        MyBoxSettings.CleanEmptyDirectoriesFeature = EditorGUILayout.Toggle(label, MyBoxSettings.CleanEmptyDirectoriesFeature);
                        GUILayout.FlexibleSpace();
                    }
                }

                EditorGUILayout.Space(80);
                using (new EditorGUILayout.VerticalScope())
                {
                    EditorGUILayout.LabelField("Performance settings", EditorStyles.miniLabel);

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        var label = new GUIContent("Prepare on Playmode: ", "Allows to use IPrepare interface with Prepare() method called automatically." +
                                                   "\nSlightly increases project Save time.");
                        MyBoxSettings.PrepareOnPlaymode = EditorGUILayout.Toggle(label, MyBoxSettings.PrepareOnPlaymode);
                        if (GUILayout.Button(MyGUI.EditorIcons.Help, EditorStyles.label, GUILayout.Height(18)))
                        {
                            Application.OpenURL("https://github.com/Deadcows/MyBox/wiki/Tools-and-Features#iprepare");
                        }
                        GUILayout.FlexibleSpace();
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        var label = new GUIContent("SO processing: ", "Allows [AutoProperty] and [MustBeAssigned] Attributes to work with Scriptable Objects." +
                                                   "\nMight increase project Save time for a few seconds.");
                        MyBoxSettings.EnableSOCheck = EditorGUILayout.Toggle(label, MyBoxSettings.EnableSOCheck);
                        GUILayout.FlexibleSpace();
                    }
                }
                GUILayout.FlexibleSpace();
            }



            MyGUI.DrawLine(Color.white, true);

            using (new EditorGUILayout.HorizontalScope())
            {
                var current          = _installedVersion == null ? "..." : _installedVersion.AsSting;
                var latest           = _latestVersion == null ? "..." : _latestVersion.AsSting;
                var installationType = MyBoxUtilities.InstalledViaUPM ? "UPM" : "(not UPM)";
                var versionStyle     = new GUIStyle(EditorStyles.miniBoldLabel);
                versionStyle.alignment = TextAnchor.MiddleCenter;
                EditorGUILayout.LabelField($@"current: {current} {installationType}. latest: {latest}", versionStyle);
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                GUI.enabled = _updateRequest == null || _updateRequest.IsCompleted;
                var updateOrInstall = MyBoxUtilities.InstalledViaUPM ? "Update" : "Install";
                if (GUILayout.Button(updateOrInstall + " UPM version", _buttonStyle, buttonWidth, buttonHeight))
                {
                    if (MyBoxUtilities.InstalledViaUPM)
                    {
                        AddPackage();
                    }
                    else
                    {
                        if (EditorUtility.DisplayDialog(
                                "Warning before installation",
                                "When UPM version will be imported you should delete current installation of MyBox",
                                "Ok, Install UPM version!", "Nah, keep it as it is"))
                        {
                            AddPackage();
                        }
                    }

                    void AddPackage()
                    {
                        _updateRequest = UnityEditor.PackageManager.Client.Add("https://github.com/Deadcows/MyBox.git");
                    }
                }

                GUI.enabled = true;

                if (GUILayout.Button("  How to Update ↗", _buttonStyle, buttonWidth, buttonHeight))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/wiki/Installation");
                }

                if (GUILayout.Button("  Releases ↗", _buttonStyle, buttonWidth, buttonHeight))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/releases");
                }

                if (GUILayout.Button("  Changelog ↗", _buttonStyle, buttonWidth, buttonHeight))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/blob/master/CHANGELOG.md");
                }

                GUILayout.FlexibleSpace();
            }

            MyGUI.DrawLine(Color.white, true);

            EditorGUILayout.LabelField("MyGUI.Colors References", new GUIStyle(EditorStyles.centeredGreyMiniLabel));
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                DrawColors();
                GUILayout.FlexibleSpace();
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("MyGUI.EditorIcons References + with black color tint", new GUIStyle(EditorStyles.centeredGreyMiniLabel));
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                DrawIcons();
                GUILayout.FlexibleSpace();
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                var c = GUI.contentColor;
                GUI.contentColor = Color.black;
                DrawIcons();
                GUI.contentColor = c;
                GUILayout.FlexibleSpace();
            }

            EditorGUILayout.Space(40);
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                var sponsorButtonStyle = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
                sponsorButtonStyle.fontSize *= 2;
                sponsorButtonStyle.fontStyle = FontStyle.Italic;
                if (GUILayout.Button("buy me a coffee :)", sponsorButtonStyle, GUILayout.Height(32)))
                {
                    Application.OpenURL("https://www.buymeacoffee.com/andrewrumak");
                }
                GUILayout.FlexibleSpace();
            }
        }
Ejemplo n.º 3
0
        private void OnGUI()
        {
            if (_titleStyle == null)
            {
                _titleStyle           = new GUIStyle(EditorStyles.boldLabel);
                _titleStyle.fontSize  = 42;
                _titleStyle.fontStyle = FontStyle.BoldAndItalic;
                _titleStyle.alignment = TextAnchor.MiddleCenter;
            }

            if (_buttonStyle == null)
            {
                _buttonStyle = new GUIStyle(MyGUI.HelpBoxStyle);
                _buttonStyle.hover.textColor = MyGUI.Colors.Blue;
            }

            var buttonWidth  = 120;
            var buttonHeight = 30;
            var leftOffset   = 20;


            wantsMouseMove = true;
            if (Event.current.type == EventType.MouseMove)
            {
                Repaint();
            }


            //buttonStyle.hover.background = buttonStyle.active.background.WithSolidColor(Color.red);

            EditorGUILayout.Space();


            EditorGUILayout.LabelField("MyBox", _titleStyle, GUILayout.Height(60));

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("  Github Page ↗", _buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox");
                }

                if (GUILayout.Button("  Attributes ↗", _buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/wiki/Attributes");
                }

                if (GUILayout.Button("  Extensions ↗", _buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/tree/master/Extensions");
                }

                if (GUILayout.Button("  Tools, Features ↗", _buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/wiki/Tools-and-Features");
                }

                GUILayout.FlexibleSpace();
            }

            MyGUI.DrawLine(Color.white, true);

            EditorGUILayout.LabelField("MyBox Settings", new GUIStyle(EditorStyles.centeredGreyMiniLabel));

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.Space(leftOffset);
                MyBoxSettings.CheckForUpdates = EditorGUILayout.Toggle("Check for Updates: ", MyBoxSettings.CheckForUpdates);
                GUILayout.FlexibleSpace();
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.Space(leftOffset);
                MyBoxSettings.AutoSaveEnabled = EditorGUILayout.Toggle("AutoSave on Play: ", MyBoxSettings.AutoSaveEnabled);
                GUILayout.FlexibleSpace();
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.Space(leftOffset);
                MyBoxSettings.CleanEmptyDirectoriesFeature = EditorGUILayout.Toggle("Clean Empty Folders: ", MyBoxSettings.CleanEmptyDirectoriesFeature);
                GUILayout.FlexibleSpace();
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.Space(leftOffset);
                MyBoxSettings.PrepareOnPlaymode = EditorGUILayout.Toggle("Prepare on Playmode: ", MyBoxSettings.PrepareOnPlaymode);
                if (GUILayout.Button(MyGUI.EditorIcons.Help, EditorStyles.label, GUILayout.Height(18)))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/wiki/Tools-and-Features#iprepare");
                }
                GUILayout.FlexibleSpace();
            }

            MyGUI.DrawLine(Color.white, true);

            using (new EditorGUILayout.HorizontalScope())
            {
                var current          = _installedVersion == null ? "..." : _installedVersion.AsSting;
                var latest           = _latestVersion == null ? "..." : _latestVersion.AsSting;
                var installationType = MyBoxUtilities.InstalledViaUPM ? "UPM" : "(not UPM)";
                var versionStyle     = new GUIStyle(EditorStyles.miniBoldLabel);
                versionStyle.alignment = TextAnchor.MiddleCenter;
                EditorGUILayout.LabelField($@"current: {current} {installationType}. latest: {latest}", versionStyle);
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                GUI.enabled = _updateRequest == null || _updateRequest.IsCompleted;
                var updateOrInstall = MyBoxUtilities.InstalledViaUPM ? "Update" : "Install";
                if (GUILayout.Button(updateOrInstall + " UPM version", _buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
                {
                    if (MyBoxUtilities.InstalledViaUPM)
                    {
                        AddPackage();
                    }
                    else
                    {
                        if (EditorUtility.DisplayDialog(
                                "Warning before installation",
                                "When UPM version will be imported you should delete current installation of MyBox",
                                "Ok, Install UPM version!", "Nah, keep it as it is"))
                        {
                            AddPackage();
                        }
                    }

                    void AddPackage()
                    {
                        _updateRequest = UnityEditor.PackageManager.Client.Add("https://github.com/Deadcows/MyBox.git");
                    }
                }

                GUI.enabled = true;

                if (GUILayout.Button("  How to Update ↗", _buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/wiki/Installation");
                }

                if (GUILayout.Button("  Releases ↗", _buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/releases");
                }

                if (GUILayout.Button("  Changelog ↗", _buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
                {
                    Application.OpenURL("https://github.com/Deadcows/MyBox/blob/master/CHANGELOG.md");
                }

                GUILayout.FlexibleSpace();
            }

            MyGUI.DrawLine(Color.white, true);

            EditorGUILayout.LabelField("MyGUI.Colors References", new GUIStyle(EditorStyles.centeredGreyMiniLabel));
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                DrawColors();
                GUILayout.FlexibleSpace();
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("MyGUI.EditorIcons References + with black color tint", new GUIStyle(EditorStyles.centeredGreyMiniLabel));
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                DrawIcons();
                GUILayout.FlexibleSpace();
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                var c = GUI.contentColor;
                GUI.contentColor = Color.black;
                DrawIcons();
                GUI.contentColor = c;
                GUILayout.FlexibleSpace();
            }
        }
Ejemplo n.º 4
0
    // Draw the property inside the given rect
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var e = Editor.CreateEditor(property.objectReferenceValue);

        position.height = EditorGUI.GetPropertyHeight(property);

        if (e != null)
        {
            var w = position.width;
            position.width = 20;
            if (GUI.Button(position, _folded ? "+" : "-", EditorStyles.toolbarButton))
            {
                _folded = !_folded;
            }
            position.width = w - 25;
            position.x    += 25;
            EditorGUIUtility.labelWidth -= 25;
            EditorGUI.PropertyField(position, property);
            EditorGUIUtility.labelWidth += 25;
            position.x    -= 25;
            position.width = w;
        }
        else
        {
            EditorGUI.PropertyField(position, property);
        }

        position.y += EditorGUI.GetPropertyHeight(property);

        if (_folded)
        {
            return;
        }

        if (e != null)
        {
            position.x     += 20;
            position.width -= 40;

            position = MyGUI.DrawLine(MyGUI.Gray, position);

            var so = e.serializedObject;
            so.Update();

            var prop = so.GetIterator();
            prop.NextVisible(true);
            while (prop.NextVisible(true))
            {
                position.height = EditorGUI.GetPropertyHeight(prop);
                EditorGUI.PropertyField(position, prop);
                position.y += EditorGUI.GetPropertyHeight(prop) + 4;
            }
            if (GUI.changed)
            {
                so.ApplyModifiedProperties();
            }

            position.y -= 4;
            MyGUI.DrawLine(MyGUI.Gray, position);
        }
    }