/// <summary>
        /// Draw title control for list field.
        /// </summary>
        /// <remarks>
        ///     <para>When needed, should be shown immediately before list field.</para>
        /// </remarks>
        /// <example>
        ///     <code language="csharp"><![CDATA[
        /// ReorderableListGUI.Title(titleContent);
        /// ReorderableListGUI.ListField(list, DynamicListGU.TextFieldItemDrawer);
        /// ]]></code>
        ///     <code language="unityscript"><![CDATA[
        /// ReorderableListGUI.Title(titleContent);
        /// ReorderableListGUI.ListField(list, DynamicListGU.TextFieldItemDrawer);
        /// ]]></code>
        /// </example>
        /// <param name="title">Content for title control.</param>
        public static void Title(GUIContent title)
        {
            var position = GUILayoutUtility.GetRect(title, ReorderableListStyles.Title);

            Title(position, title);
            LudiqGUI.Space(-1);
        }
Beispiel #2
0
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background);

            GUILayout.Label(new GUIContent(changelog.plugin.manifest.name), Styles.plugin);
            LudiqGUI.Space(2);
            GUILayout.Label(new GUIContent($"Version {changelog.version}"), Styles.version);

            if (!StringUtility.IsNullOrWhiteSpace(changelog.description))
            {
                LudiqGUI.Space(5);
                GUILayout.Label(new GUIContent(changelog.description.Trim()), Styles.description);
            }

            foreach (var change in changes)
            {
                LudiqGUI.Space(10);
                GUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
                GUILayout.Label(GUIContent.none, Styles.bullet);
                GUILayout.Label(change.type, Styles.changeType);
                GUILayout.Label(change.content, Styles.changeContent);
                LudiqGUI.EndHorizontal();
            }

            LudiqGUI.EndVertical();
        }
Beispiel #3
0
        protected override void OnHeaderGUI()
        {
            if (mainAboutable == null || mainAboutable.logo == null)
            {
                base.OnHeaderGUI();
                return;
            }

            GUILayout.BeginVertical(LudiqStyles.windowHeaderBackground, GUILayout.ExpandWidth(true));
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var logoHeight   = Styles.logoHeight;
            var logoWidth    = (float)mainAboutable.logo.width / mainAboutable.logo.height * logoHeight;
            var logoPosition = GUILayoutUtility.GetRect(logoWidth, logoHeight);

            GUI.DrawTexture(logoPosition, mainAboutable.logo);

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(13);
            OnTabsGUI();
            LudiqGUI.Space(-5);

            LudiqGUI.EndVertical();
        }
Beispiel #4
0
            public void OnGUI()
            {
                LudiqGUI.BeginHorizontal();

                GUILayout.Box(GetStateIcon(state)?[IconSize.Small], Styles.stepIcon);

                GUILayout.Label(label, state == State.Idle ? Styles.stepIdleIcon : Styles.stepLabel, GUILayout.ExpandWidth(false));

                LudiqGUI.Space(5);

                if (logPath != null)
                {
                    if (GUILayout.Button("Show Log", Styles.stepShowLogButton, GUILayout.ExpandWidth(false)))
                    {
                        Process.Start(logPath);
                    }
                }
                else
                {
                    GUILayout.Label("Show Log", Styles.stepShowLogHiddenButton, GUILayout.ExpandWidth(false));
                }

                LudiqGUI.EndHorizontal();

                if (Event.current.type == EventType.Repaint)
                {
                    lastDrawnState = state;
                }
            }
Beispiel #5
0
        private void OnFooterGUI(SettingsScope scope)
        {
            if (!PluginContainer.initialized)
            {
                return;
            }

            LudiqGUI.BeginVertical(Styles.background);

            LudiqGUI.Space(8);

            if (GUILayout.Button("Reset to Defaults"))
            {
                if (EditorUtility.DisplayDialog("Reset to Defaults", $"Are you sure you want to reset your {ScopeName(scope).ToLower()} to default?", "Reset", "Cancel"))
                {
                    foreach (var item in this[scope])
                    {
                        item.Reset();
                        OnItemChange(item);
                        item.Save();
                    }

                    InternalEditorUtility.RepaintAllViews();
                }
            }

            LudiqGUI.Space(8);

            LudiqGUI.EndVertical();
        }
Beispiel #6
0
        protected override void OnHeaderGUI()
        {
            if (currentPage == null)
            {
                base.OnHeaderGUI();
                return;
            }

            GUILayout.BeginVertical(LudiqStyles.windowHeaderBackground, GUILayout.ExpandWidth(true));
            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            LudiqGUI.FlexibleSpace();

            if (currentPage?.icon != null)
            {
                GUILayout.Box(new GUIContent(currentPage.icon?[(int)LudiqStyles.windowHeaderIcon.fixedWidth]), LudiqStyles.windowHeaderIcon);
                LudiqGUI.Space(LudiqStyles.spaceBetweenWindowHeaderIconAndTitle);
            }

            GUILayout.Label(title, LudiqStyles.windowHeaderTitle);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(13);
            OnTabsGUI();
            LudiqGUI.Space(-5);

            LudiqGUI.EndVertical();
        }
Beispiel #7
0
        public void OnGUI(SettingsScope scope, string query)
        {
            if (!PluginContainer.initialized)
            {
                return;
            }

            if (editor == null)
            {
                editor = accessor.CreateInitializedEditor();
            }

            LudiqGUI.BeginVertical(Styles.background);

            EditorGUI.BeginChangeCheck();

            using (Inspector.expandTooltip.Override(true))
            {
                foreach (var item in this[scope].Where(i => i.visible))
                {
                    EditorGUI.BeginChangeCheck();

                    LudiqGUI.Space(2);

                    if (!string.IsNullOrEmpty(query))
                    {
                        var haystack = Haystack(item);

                        var matchesSearch = SearchUtility.Matches(query, haystack);

                        using (LudiqGUI.color.Override(matchesSearch ? Color.white : Color.white.WithAlphaMultiplied(0.5f)))
                            using (LudiqGUIUtility.LabelHighlight(query))
                            {
                                editor.ChildInspector(item).DrawFieldLayout();
                            }
                    }
                    else
                    {
                        editor.ChildInspector(item).DrawFieldLayout();
                    }

                    LudiqGUI.Space(2);

                    if (EditorGUI.EndChangeCheck())
                    {
                        OnItemChange(item);
                    }
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                Save();
                InternalEditorUtility.RepaintAllViews();
            }

            LudiqGUI.EndVertical();
        }
            public override void OnGUI()
            {
                if (PluginContainer.anyVersionMismatch)
                {
                    LudiqGUI.VersionMismatchShieldLayout();
                    return;
                }

                accessor.UpdatePrefabModifications();

                EditorGUI.BeginChangeCheck();

                LudiqGUI.Space(EditorGUIUtility.standardVerticalSpacing);

                editor.DrawControlLayout(21);

                if (editor.isHeightDirty)
                {
                    rootEditor.Repaint();
                }

                if (EditorGUI.EndChangeCheck())
                {
                    rootEditor.Repaint();
                }

                if (LudiqCore.Configuration.developerMode && LudiqCore.Configuration.developerEditorMenu)
                {
                    debugFoldout = EditorGUILayout.Foldout(debugFoldout, "Developer", true);

                    if (debugFoldout)
                    {
                        var target = serializedObject.targetObject;

                        if (GUILayout.Button("Show Serialized Data"))
                        {
                            ((ILudiqRootObject)target).ShowData();
                        }

                        EditorGUI.BeginDisabledGroup(true);
                        EditorGUILayout.Toggle("Prefab definition", target.IsPrefabDefinition());
                        EditorGUILayout.Toggle("Prefab instance", target.IsPrefabInstance());
                        EditorGUILayout.Toggle("Connected prefab instance", target.IsConnectedPrefabInstance());
                        EditorGUILayout.Toggle("Disconnected prefab instance", target.IsDisconnectedPrefabInstance());
                        EditorGUILayout.Toggle("Scene bound", target.IsSceneBound());
                        EditorGUILayout.ObjectField("Prefab definition", target.GetPrefabDefinition(), typeof(Object), true);
                        EditorGUI.EndDisabledGroup();
                    }
                }
                else
                {
                    LudiqGUI.Space(EditorGUIUtility.standardVerticalSpacing);
                }
            }
Beispiel #9
0
        public static void DrawPluginVersionTable(IEnumerable <Plugin> plugins)
        {
            var savedColumnHeader     = new GUIContent("Saved");
            var installedColumnHeader = new GUIContent("Installed");

            var pluginsColumnWidth   = 0f;
            var savedColumnWidth     = Styles.columnHeader.CalcSize(savedColumnHeader).x;
            var installedColumnWidth = Styles.columnHeader.CalcSize(installedColumnHeader).x;
            var stateColumnWidth     = 0f;

            foreach (var plugin in plugins)
            {
                pluginsColumnWidth   = Mathf.Max(pluginsColumnWidth, Styles.pluginName.CalcSize(new GUIContent(plugin.manifest.name)).x);
                savedColumnWidth     = Mathf.Max(savedColumnWidth, Styles.version.CalcSize(new GUIContent(plugin.manifest.savedVersion.ToString())).x);
                installedColumnWidth = Mathf.Max(installedColumnWidth, Styles.version.CalcSize(new GUIContent(plugin.manifest.currentVersion.ToString())).x);
                stateColumnWidth     = Mathf.Max(stateColumnWidth, Styles.state.CalcSize(VersionStateContent(plugin)).x);
            }

            LudiqGUI.BeginVertical();

            // Header row
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(GUIContent.none, Styles.columnHeader, GUILayout.Width(pluginsColumnWidth));
            LudiqGUI.Space(Styles.columnSpacing);
            GUILayout.Label(savedColumnHeader, Styles.columnHeader, GUILayout.Width(savedColumnWidth));
            LudiqGUI.Space(Styles.columnSpacing);
            GUILayout.Label(installedColumnHeader, Styles.columnHeader, GUILayout.Width(installedColumnWidth));
            LudiqGUI.Space(Styles.columnSpacing);
            GUILayout.Label(GUIContent.none, Styles.state, GUILayout.Width(stateColumnWidth));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            // Plugin rows
            foreach (var plugin in plugins)
            {
                LudiqGUI.Space(Styles.rowSpacing);

                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                GUILayout.Label(new GUIContent(plugin.manifest.name), Styles.pluginName, GUILayout.Width(pluginsColumnWidth));
                LudiqGUI.Space(Styles.columnSpacing);
                GUILayout.Label(new GUIContent(plugin.manifest.savedVersion.ToString()), Styles.version, GUILayout.Width(savedColumnWidth));
                LudiqGUI.Space(Styles.columnSpacing);
                GUILayout.Label(new GUIContent(plugin.manifest.currentVersion.ToString()), Styles.version, GUILayout.Width(installedColumnWidth));
                LudiqGUI.Space(Styles.columnSpacing);
                GUILayout.Label(VersionStateContent(plugin), Styles.state, GUILayout.Width(stateColumnWidth));
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();
            }

            LudiqGUI.EndVertical();
        }
Beispiel #10
0
        protected override void OnContentGUI()
        {
            if (!plugins.Any())
            {
                Complete();
            }

            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));
            LudiqGUI.FlexibleSpace();
            GUILayout.Label($"The following plugins have been downgraded to a previous version: ", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();
            UpdateWizard.DrawPluginVersionTable(plugins);
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("This will likely cause backwards incompatibility issues.", LudiqStyles.centeredLabel);
            GUILayout.Label("We recommend that you re-install their saved version to avoid data corruption.", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Close", Styles.button))
            {
                window.Close();
            }

            LudiqGUI.Space(10);

            if (GUILayout.Button("Force Consolidate", Styles.button))
            {
                var consolidationExplanation = string.Empty;
                consolidationExplanation += $"By forcing consolidation, the saved versions will be set to match the installed versions. ";
                consolidationExplanation += "This does not roll back updates and may lead to data corruption. ";
                consolidationExplanation += "You should only do this if you know what you are doing. ";
                consolidationExplanation += "A backup will be created automatically if you decide to proceed.";

                if (EditorUtility.DisplayDialog("Force Consolidate Version", consolidationExplanation, "Force Consolidate", "Cancel"))
                {
                    foreach (var plugin in plugins)
                    {
                        plugin.manifest.savedVersion = plugin.manifest.currentVersion;
                    }

                    Complete();
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndVertical();
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background);

            GUILayout.Label(acknowledgement.title, Styles.title);

            var hasAuthor    = !StringUtility.IsNullOrWhiteSpace(acknowledgement.author);
            var hasCopyright = acknowledgement.copyrightYear != null;

            if (hasAuthor && hasCopyright)
            {
                GUILayout.Label($"Copyright \u00a9 {acknowledgement.copyrightYear} {acknowledgement.author}", Styles.property);
            }
            else if (hasAuthor)
            {
                GUILayout.Label($"Author: {acknowledgement.author}", Styles.property);
            }
            else if (hasCopyright)
            {
                GUILayout.Label($"Copyright \u00a9 {acknowledgement.copyrightYear}", Styles.property);
            }

            if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.url))
            {
                if (GUILayout.Button(acknowledgement.url, Styles.url))
                {
                    Process.Start(acknowledgement.url);
                }
            }

            if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.licenseName))
            {
                GUILayout.Label("License: " + acknowledgement.licenseName.Trim(), Styles.property);
            }

            LudiqGUI.EndVertical();

            if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.licenseText))
            {
                GUILayout.Box(GUIContent.none, LudiqStyles.horizontalSeparator);

                licenseScroll = GUILayout.BeginScrollView(licenseScroll, Styles.licenseBackground);

                GUILayout.Label(licenseText, Styles.licenseText);

                GUILayout.EndScrollView();

                LudiqGUI.Space(-1);
            }
        }
            public void OnGUI()
            {
                LudiqGUI.BeginHorizontal();

                GUILayout.Box(GetStateIcon(state)?[IconSize.Small], Styles.stepIcon);

                GUILayout.Label($"{plugin.manifest.name}: Version {migration.@from} to version {migration.to}", state == State.Idle ? Styles.stepIdleLabel : Styles.stepLabel, GUILayout.ExpandWidth(false));

                LudiqGUI.Space(5);

                if (exception != null)
                {
                    if (GUILayout.Button("Show Error", Styles.stepShowErrorButton, GUILayout.ExpandWidth(false)))
                    {
                        Debug.LogException(exception);
                        EditorUtility.DisplayDialog("Update Error", $"{exception.HumanName()}:\n\n{exception.Message}\n\n(Full trace shown in log)", "OK");
                    }
                }

                LudiqGUI.EndHorizontal();
            }
Beispiel #13
0
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();
            GUILayout.Label($"Plugins have been updated.", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();

            if (hasChangelogs)
            {
                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();

                if (GUILayout.Button("Show Changelogs", Styles.button))
                {
                    Complete();
                }

                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();

                LudiqGUI.Space(10);
            }

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Close", Styles.button))
            {
                throw new WindowClose();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
        private void OnGUI()
        {
            var sidePanelWidth = CalculateSidePanelWidth();

            GUILayout.BeginArea(new Rect(0, 0, sidePanelWidth, position.height), GUI.skin.box);

            DrawIconDisplay(_selectedIcon);
            GUILayout.EndArea();

            GUI.BeginGroup(new Rect(sidePanelWidth, 0, position.width - sidePanelWidth, position.height));
            _scrollPos = GUILayout.BeginScrollView(_scrollPos, true, true, GUILayout.MaxWidth(position.width - sidePanelWidth));

            for (var i = 0; i < iconGroups.Count; ++i)
            {
                var group = iconGroups[i];
                EditorGUILayout.LabelField(group.name);
                DrawIconSelectionGrid(group.iconData, group.maxWidth);

                LudiqGUI.Space(15);
            }

            GUILayout.EndScrollView();
            GUI.EndGroup();
        }
        protected override void OnHeaderGUI()
        {
            if (product.logo == null)
            {
                base.OnHeaderGUI();
                return;
            }

            GUILayout.BeginVertical(LudiqStyles.windowHeaderBackground);

            LudiqGUI.Space(-5);

            // Welcome label
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("Welcome to", Styles.welcome);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            // Logo
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (product.logo != null)
            {
                var logoHeight   = Styles.productLogoHeight;
                var logoWidth    = (float)product.logo.width / product.logo.height * logoHeight;
                var logoPosition = GUILayoutUtility.GetRect(logoWidth, logoHeight);
                GUI.DrawTexture(logoPosition, product.logo);
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.EndVertical();
        }
Beispiel #16
0
            public override void OnGUI()
            {
                if (EditorApplication.isCompiling)
                {
                    LudiqGUI.CenterLoader();
                    return;
                }

                using (LudiqEditorUtility.editedObject.Override(serializedObject.targetObject))
                {
                    if (PluginContainer.anyVersionMismatch)
                    {
                        LudiqGUI.VersionMismatchShieldLayout();
                        return;
                    }

                    if (inspector == null)
                    {
                        inspector = metadata.Editor();
                    }

                    EditorGUI.BeginChangeCheck();

                    LudiqGUI.Space(EditorGUIUtility.standardVerticalSpacing);

                    inspector.DrawLayout(GUIContent.none, 20);

                    if (EditorGUI.EndChangeCheck())
                    {
                        editorParent.Repaint();
                    }

                    if (LudiqCore.Configuration.developerMode)
                    {
                        debugFoldout = EditorGUILayout.Foldout(debugFoldout, "Developer", true);

                        if (debugFoldout)
                        {
                            var target = serializedObject.targetObject;

                            if (GUILayout.Button("Show Serialized Data"))
                            {
                                ((SerializationData)dataProperty.GetUnderlyingValue()).ShowString(target.ToString());
                            }

                            EditorGUI.BeginDisabledGroup(true);
                            EditorGUILayout.PropertyField(dataProperty.FindPropertyRelativeOrFail("_" + nameof(SerializationData.objectReferences)));
                            EditorGUILayout.Toggle("Prefab definition", target.IsPrefabDefinition());
                            EditorGUILayout.Toggle("Prefab instance", target.IsPrefabInstance());
                            EditorGUILayout.Toggle("Connected prefab instance", target.IsConnectedPrefabInstance());
                            EditorGUILayout.Toggle("Disconnected prefab instance", target.IsDisconnectedPrefabInstance());
                            EditorGUILayout.Toggle("Scene bound", target.IsSceneBound());
                            EditorGUILayout.ObjectField("Prefab definition", target.GetPrefabDefinition(), typeof(UnityEngine.Object), true);
                            EditorGUI.EndDisabledGroup();
                        }
                    }
                    else
                    {
                        LudiqGUI.Space(EditorGUIUtility.standardVerticalSpacing);
                    }
                }
            }
Beispiel #17
0
        private void Draw()
        {
            if (Event.current.type == EventType.Layout)
            {
                UpdateDrawnElements();
            }

            LudiqGUI.BeginVertical(Styles.background);

            LudiqGUI.BeginHorizontal(Styles.tipArea, GUILayout.Height(Styles.tipHeight));

            LudiqGUI.BeginVertical();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.LoaderLayout();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndVertical();

            if (drawnTip != null)
            {
                LudiqGUI.Space(Styles.spaceBetweenSpinnerAndTip);

                LudiqGUI.BeginVertical();
                LudiqGUI.FlexibleSpace();
                GUILayout.Label("<b>Tip:</b> " + drawnTip, Styles.tip);
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndVertical();
            }

            LudiqGUI.EndHorizontal();

            if (drawnTasks.Count > 0)
            {
                var first = true;

                foreach (var task in drawnTasks)
                {
                    if (!first)
                    {
                        GUILayout.Space(Styles.spaceBetweenTasks);
                    }

                    if (Event.current.type == EventType.Layout)
                    {
                        task.animatedRatio = Mathf.MoveTowards(task.animatedRatio, task.ratio, progressAnimationSpeed * repaintDeltaTime);
                    }

                    LudiqGUI.BeginVertical(Styles.task);

                    GUILayout.Label(task.title + $" <color=#{ColorPalette.unityForegroundDim.ToHexString()}>({task.elapsed.TotalSeconds:###0.0} seconds)</color>", Styles.taskTitle);

                    var progressBarPosition = EditorGUILayout.GetControlRect();

                    EditorGUI.ProgressBar(progressBarPosition, task.animatedRatio, null);

                    if (task.stepsHaveStarted)
                    {
                        var currentItemPosition = new Rect
                                                  (
                            progressBarPosition.x + (int)(task.animatedRatio * progressBarPosition.width) - 1,
                            progressBarPosition.y,
                            Mathf.Max(3, Mathf.CeilToInt((1f / task.totalSteps) * (progressBarPosition.width)) + 1),
                            progressBarPosition.height
                                                  );

                        if (Event.current.type == EventType.Repaint)
                        {
                            var opacity = Mathf.Lerp(0.25f, 0.25f, (Mathf.Sin((float)EditorApplication.timeSinceStartup * 3) + 1) / 2);

                            using (LudiqGUI.color.Override(LudiqGUI.color.value.WithAlphaMultiplied(opacity)))
                            {
                                Styles.currentItemFill.Draw(currentItemPosition, false, false, false, false);
                            }
                        }

                        LudiqGUI.DrawEmptyRect(currentItemPosition, Styles.currentItemBorder);

                        if (Event.current.type == EventType.Repaint)
                        {
                            Styles.currentItemText.Draw(progressBarPosition, new GUIContent(task.currentStepLabel), false, false, false, false);
                        }
                    }

                    LudiqGUI.EndVertical();

                    first = false;
                }
            }

            LudiqGUI.EndVertical();
        }
Beispiel #18
0
        protected override void OnContentGUI()
        {
            var previousIconSize = EditorGUIUtility.GetIconSize();

            EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

            var explanation = "Bolt plugins can automatically display documentation for Unity methods in graphs and in the inspector. ";

            explanation += "To also include documentation from your custom code and from third-party plugins, we need to generate it first.";

            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(explanation, Styles.explanationLabel, GUILayout.MaxWidth(350));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(queue.Count > 0);

            if (GUILayout.Button("Generate Documentation", Styles.generateButton))
            {
                foreach (var step in steps)
                {
                    step.Reset();
                }

                foreach (var step in steps)
                {
                    queue.Enqueue(step);
                }

                queue.Peek().Generate();
                generating = true;
            }

            EditorGUI.EndDisabledGroup();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginVertical();

            foreach (var step in steps)
            {
                step.OnGUI();

                LudiqGUI.Space(Styles.spaceBetweenSteps);
            }

            LudiqGUI.EndVertical();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(generating);
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.nextButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            LudiqGUI.FlexibleSpace();
            GUILayout.Label("You can regenerate documentation at any time from the tools menu.", EditorStyles.centeredGreyMiniLabel);

            LudiqGUI.EndVertical();

            EditorGUIUtility.SetIconSize(previousIconSize);
        }
Beispiel #19
0
        protected override void OnContentGUI()
        {
            var previousIconSize = EditorGUIUtility.GetIconSize();

            EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            var question = "How do you want names to be displayed?" + "\n";

            question += "If you're not an experienced programmer, we recommend Human Naming.";

            LudiqGUI.FlexibleSpace();
            GUILayout.Label(question, LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginVertical();

            if (GUILayout.Button("Human Naming", Styles.modeButton))
            {
                LudiqCore.Configuration.humanNaming = true;
                LudiqCore.Configuration.Save();
                Complete();
            }

            LudiqGUI.Space(-1);
            GUILayout.BeginVertical(Styles.modeBox);
            GUILayout.Label(new GUIContent(" Transform: Get Position", typeof(Transform).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" Integer", typeof(int).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" List of Game Object", typeof(List <GameObject>).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" Rigidbody: Add Force (Force)", typeof(Rigidbody).Icon()[IconSize.Small]), Styles.example);
            LudiqGUI.EndVertical();
            LudiqGUI.EndVertical();

            LudiqGUI.Space(10);

            LudiqGUI.BeginVertical();

            if (GUILayout.Button("Programmer Naming", Styles.modeButton))
            {
                LudiqCore.Configuration.humanNaming = false;
                LudiqCore.Configuration.Save();
                Complete();
            }

            LudiqGUI.Space(-1);
            GUILayout.BeginVertical(Styles.modeBox);
            GUILayout.Label(new GUIContent(" Transform.position (Get)", typeof(Transform).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" int", typeof(int).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" List<GameObject>", typeof(List <GameObject>).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" Rigidbody.AddForce(force)", typeof(Rigidbody).Icon()[IconSize.Small]), Styles.example);
            LudiqGUI.EndVertical();
            LudiqGUI.EndVertical();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("You can change this setting at any time from the setup or configuration.", EditorStyles.centeredGreyMiniLabel);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();

            EditorGUIUtility.SetIconSize(previousIconSize);
        }
Beispiel #20
0
        protected override void OnContentGUI()
        {
            if (!migrations.SelectMany(m => m.requiredActions).Any())
            {
                Complete();
            }

            scroll = GUILayout.BeginScrollView(scroll, Styles.background, GUILayout.ExpandHeight(true));
            LudiqGUI.BeginVertical();

            LudiqGUI.Space(Styles.space);
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("The following required update actions could not be completed automatically. Please complete them before continuing to use the plugin.", LudiqStyles.centeredLabel, GUILayout.MaxWidth(340));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.Space(Styles.space);

            foreach (var migration in migrations)
            {
                if (!migration.requiredActions.Any())
                {
                    continue;
                }

                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                GUILayout.BeginVertical(GUILayout.MaxWidth(300));

                LudiqGUI.BeginHorizontal();
                GUILayout.Box(BoltCore.Icons.warningMessage?[IconSize.Small], Styles.migrationIcon);
                GUILayout.Label($"{migration.plugin.manifest.name}, v.{migration.@from} to v.{migration.to}: ", Styles.migration);
                LudiqGUI.EndHorizontal();

                foreach (var requiredAction in migration.requiredActions)
                {
                    LudiqGUI.Space(5);
                    LudiqGUI.BeginHorizontal();
                    GUILayout.Box(GUIContent.none, Styles.requiredActionBullet);
                    GUILayout.Label(requiredAction, Styles.requiredAction);
                    LudiqGUI.EndHorizontal();
                }

                LudiqGUI.EndVertical();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();

                LudiqGUI.Space(Styles.space);
            }

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(Styles.space);
            LudiqGUI.EndVertical();
            GUILayout.EndScrollView();
        }
Beispiel #21
0
        private void OnOptionsGUI(float anim, FuzzyOptionNode parent)
        {
            var hasHeader         = !string.IsNullOrEmpty(parent.option.headerLabel);
            var headerHeight      = hasHeader ? Styles.headerHeight : 0;
            var searchFieldHeight = tree.searchable ? LudiqStyles.searchFieldOuterHeight : 0;

            var levelPosition = new Rect
                                (
                position.width * (1 - anim) + 1,
                searchFieldHeight + headerHeight,
                position.width - 2,
                height - (searchFieldHeight + 1) - headerHeight
                                );

            if (e.type == EventType.MouseDown && e.button == (int)MouseButton.Right && levelPosition.Contains(e.mousePosition))
            {
                SelectParent();
                e.Use();
            }

            GUILayout.BeginArea(levelPosition);

            if (parent.isLoading)
            {
                LudiqGUI.BeginVertical();
                LudiqGUI.FlexibleSpace();

                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.LoaderLayout();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();

                LudiqGUI.Space(16);

                LudiqGUI.BeginHorizontal();
                LudiqGUI.Space(10);
                var progressBarPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(19), GUILayout.ExpandWidth(true));
                if (showProgress)
                {
                    EditorGUI.ProgressBar(progressBarPosition, progress, progressText);
                }

                LudiqGUI.Space(10);
                LudiqGUI.EndHorizontal();
                LudiqGUI.Space(LudiqGUI.loaderSize * 1.5f);

                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndVertical();
                Repaint();
            }
            else
            {
                parent.scroll = GUILayout.BeginScrollView(parent.scroll);

                EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

                var selectedOptionPosition = default(Rect);

                foreach (var node in parent.children)
                {
                    node.EnsurePositionable();

                    if (e.type == EventType.Layout || e.type == EventType.Repaint)
                    {
                        minOptionWidth = Mathf.Max(minOptionWidth, Mathf.Min(node.width, Styles.maxOptionWidth));
                    }
                }

                for (var i = 0; i < parent.children.Count; i++)
                {
                    var node        = parent.children[i];
                    var isSeparator = node.option is FuzzySeparator;

                    var optionPosition = GUILayoutUtility.GetRect(IconSize.Small, isSeparator ? Styles.separator.fixedHeight : Styles.optionHeight, GUILayout.ExpandWidth(true));

                    if (((e.type == EventType.MouseMove && GUIUtility.GUIToScreenPoint(e.mousePosition) != lastMouseMovePosition) || e.type == EventType.MouseDown) &&
                        parent.selectedIndex != i &&
                        optionPosition.Contains(e.mousePosition))
                    {
                        parent.selectedIndex = i;
                        Repaint();
                        lastMouseMovePosition = GUIUtility.GUIToScreenPoint(e.mousePosition);
                    }

                    var optionIsSelected = false;

                    if (i == parent.selectedIndex)
                    {
                        optionIsSelected       = true;
                        selectedOptionPosition = optionPosition;
                    }

                    // Clipping
                    if (optionPosition.yMax < parent.scroll.y || optionPosition.yMin > parent.scroll.y + levelPosition.height)
                    {
                        continue;
                    }

                    EditorGUI.BeginDisabledGroup(node.option.mode == FuzzyOptionMode.Branch && node.hasChildren == false);

                    node.EnsureDrawable();

                    if (e.type == EventType.Repaint)
                    {
                        using (LudiqGUI.color.Override(node.dim ? LudiqGUI.color.value.WithAlphaMultiplied(0.66f) : LudiqGUI.color.value))
                        {
                            if (node.option is FuzzySeparator)
                            {
                                Styles.separator.Draw(optionPosition, node.label, false, false, false, false);

                                var linePosition = new Rect(optionPosition.x, optionPosition.yMax - 1, optionPosition.width, 1);

                                Styles.separatorLine.Draw(linePosition, GUIContent.none, false, false, false, false);
                            }
                            else
                            {
                                Styles.optionBackground.Draw(optionPosition, GUIContent.none, false, false, optionIsSelected, optionIsSelected);

                                float x = Styles.optionBackground.padding.left;

                                var spaced = false;

                                foreach (var icon in node.icons)
                                {
                                    if (icon == null)
                                    {
                                        continue;
                                    }

                                    var iconPosition = new Rect
                                                       (
                                        optionPosition.x + x,
                                        optionPosition.y + Styles.optionBackground.padding.top,
                                        IconSize.Small,
                                        IconSize.Small
                                                       );

                                    GUI.DrawTexture(iconPosition, icon[IconSize.Small]);

                                    x     += IconSize.Small;
                                    x     += Styles.spaceBetweenIcons;
                                    spaced = true;
                                }

                                if (spaced)
                                {
                                    x -= Styles.spaceBetweenIcons;
                                    x += Styles.spaceAfterIcons;
                                }

                                var foregroundPosition = optionPosition;
                                foregroundPosition.x     += x;
                                foregroundPosition.width -= x;

                                Styles.optionForeground.Draw(foregroundPosition, node.label, false, false, optionIsSelected, optionIsSelected);
                            }
                        }
                    }

                    var right = optionPosition.xMax;

                    if (node.option.mode == FuzzyOptionMode.Branch)
                    {
                        right -= 13;
                        var rightArrowPosition = new Rect(right, optionPosition.y + 4, 13, 13);

                        if (e.type == EventType.Repaint)
                        {
                            Styles.rightArrow.Draw(rightArrowPosition, false, false, false, false);
                        }
                    }

                    if (node.option.mode == FuzzyOptionMode.Leaf && tree.selected.Contains(node.option.value) && !isSeparator)
                    {
                        right -= 16;
                        var checkPosition = new Rect(right, optionPosition.y + 4, 12, 12);

                        if (e.type == EventType.Repaint)
                        {
                            Styles.check.Draw(checkPosition, false, false, false, false);
                        }
                    }

                    EditorGUI.EndDisabledGroup();

                    if (tree.favorites != null && tree.CanFavorite(node.option) && (optionIsSelected || tree.favorites.Contains(node.option)))
                    {
                        right -= 19;
                        var starPosition = new Rect(right, optionPosition.y + 2, IconSize.Small, IconSize.Small);

                        EditorGUI.BeginChangeCheck();

                        var isFavorite = tree.favorites.Contains(node.option);

                        isFavorite = GUI.Toggle(starPosition, isFavorite, GUIContent.none, Styles.star);

                        if (EditorGUI.EndChangeCheck())
                        {
                            if (isFavorite)
                            {
                                tree.favorites.Add(node.option);
                            }
                            else
                            {
                                tree.favorites.Remove(node.option);
                            }

                            tree.OnFavoritesChange();

                            ExecuteTask(() => UpdateFavorites());
                        }
                    }

                    if (e.type == EventType.MouseUp && e.button == (int)MouseButton.Left && optionPosition.Contains(e.mousePosition))
                    {
                        e.Use();
                        parent.selectedIndex = i;
                        SelectChild(node);
                    }
                }

                EditorGUIUtility.SetIconSize(default(Vector2));

                GUILayout.EndScrollView();

                if (scrollToSelected && e.type == EventType.Repaint)
                {
                    scrollToSelected = false;

                    var lastRect = GUILayoutUtility.GetLastRect();

                    if (selectedOptionPosition.yMax - lastRect.height > parent.scroll.y)
                    {
                        var scroll = parent.scroll;
                        scroll.y      = selectedOptionPosition.yMax - lastRect.height;
                        parent.scroll = scroll;
                        Repaint();
                    }

                    if (selectedOptionPosition.y < parent.scroll.y)
                    {
                        var scroll = parent.scroll;
                        scroll.y      = selectedOptionPosition.y;
                        parent.scroll = scroll;
                        Repaint();
                    }
                }
            }

            GUILayout.EndArea();
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var text = "Choose the types you want to use for variables and units.\n"
                       + "MonoBehaviour types are always included.";

            GUILayout.Label(text, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            var height = LudiqGUI.GetInspectorHeight(null, typeOptionsMetadata, Styles.optionsWidth, GUIContent.none);

            LudiqGUI.BeginHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

            LudiqGUI.Inspector(typeOptionsMetadata, position, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                typeOptionsMetadata.Save();
                Codebase.UpdateSettings();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
            {
                typeOptionsMetadata.Reset(true);
                typeOptionsMetadata.Save();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Generate", Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Beispiel #23
0
        private void OnGUI()
        {
            EditorGUI.BeginDisabledGroup(EditorApplication.isCompiling);

            scroll = GUILayout.BeginScrollView(scroll);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.BeginVertical();

            foreach (var configuration in configurations)
            {
                if (configuration.Any(i => i.visible))
                {
                    if (configurations.Count > 1)
                    {
                        Header(configuration.header.Replace(label + " ", ""));
                    }

                    EditorGUI.BeginChangeCheck();

                    using (Inspector.expandTooltip.Override(true))
                    {
                        foreach (var item in configuration.Where(i => i.visible))
                        {
                            LudiqGUI.Space(2);

                            LudiqGUI.BeginHorizontal();

                            LudiqGUI.Space(4);

                            var iconPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Width(Styles.iconSize), GUILayout.Height(Styles.iconSize), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));

                            EditorTexture icon    = null;
                            string        tooltip = null;

                            if (item is ProjectSettingMetadata)
                            {
                                icon    = BoltCore.Icons.projectSetting;
                                tooltip = "Project Setting: Shared across users, local to this project. Included in version control.";
                            }
                            else if (item is EditorPrefMetadata)
                            {
                                icon    = BoltCore.Icons.editorPref;
                                tooltip = "Editor Pref: Local to this user, shared across projects. Excluded from version control.";
                            }

                            if (icon != null)
                            {
                                using (LudiqGUI.color.Override(GUI.color.WithAlpha(0.6f)))
                                {
                                    GUI.Label(iconPosition, new GUIContent(icon[Styles.iconSize], tooltip), GUIStyle.none);
                                }
                            }

                            LudiqGUI.Space(6);

                            LudiqGUI.BeginVertical();

                            LudiqGUI.Space(-3);

                            LudiqGUI.InspectorLayout(item);

                            LudiqGUI.EndVertical();

                            LudiqGUI.EndHorizontal();
                        }
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        configuration.Save();
                        InternalEditorUtility.RepaintAllViews();
                    }
                }
            }

            LudiqGUI.Space(8);

            if (GUILayout.Button("Reset to Defaults"))
            {
                if (EditorUtility.DisplayDialog("Reset to Defaults", "Are you sure you want to reset your preferences and project settings to default?", "Reset"))
                {
                    foreach (var configuration in configurations)
                    {
                        configuration.Reset();
                        configuration.Save();
                    }

                    InternalEditorUtility.RepaintAllViews();
                }
            }

            LudiqGUI.Space(8);
            LudiqGUI.EndVertical();
            LudiqGUI.Space(8);
            LudiqGUI.EndHorizontal();
            GUILayout.EndScrollView();
            EditorGUI.EndDisabledGroup();
        }
Beispiel #24
0
 private static void Header(string text)
 {
     GUILayout.Label(text, Styles.header);
     LudiqGUI.Space(4);
 }
        protected override void OnContentGUI()
        {
            scroll = GUILayout.BeginScrollView(scroll, Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.BeginVertical();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("When you start the update, the wizard will run migrations between the previous and new version and make all required automatic changes.", LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(queue.Count > 0 || migrated);
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Update", Styles.updateButton))
            {
                foreach (var step in steps)
                {
                    step.Reset();
                }

                foreach (var step in steps)
                {
                    queue.Enqueue(step);
                }

                queue.Peek().Run();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginVertical();

            foreach (var step in steps)
            {
                step.OnGUI();

                LudiqGUI.Space(Styles.spaceBetweenSteps);
            }

            LudiqGUI.EndVertical();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(!migrated);
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();

            GUILayout.EndScrollView();
        }
Beispiel #26
0
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();
            LudiqGUI.FlexibleSpace();

            var paragraph = incentive;

            paragraph += " Here, you can create a zip of your assets folder automatically and store it under 'Project\u00a0/\u00a0Backups'.)";

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(paragraph, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Create Backup", Styles.createBackupButton))
            {
                try
                {
                    BackupUtility.BackupAssetsFolder();
                    createdBackup = true;
                }
                catch (Exception ex)
                {
                    EditorUtility.DisplayDialog("Backup Error", "Failed to create backup:\n\n" + ex.Message, "OK");
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            if (createdBackup)
            {
                GUILayout.Label(new GUIContent(" Backup created", BoltCore.Icons.successState?[IconSize.Small]), Styles.backupCreatedLabel);
            }
            else
            {
                LudiqGUI.Space(Styles.backupCreatedLabel.fixedHeight + 2);
            }

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            OnCloseButtonGUI();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
        private void OnGUI()
        {
            try
            {
                lock (guiLock)
                {
                    //This variable should not be null, but when we click the play button the FuzzyFinder (DropDown window) does not close on 2019 and 2020
                    //but it does close on 2018.
                    //The FuzzyFinder (DropDown window) should close if you click anywhere in the Editor
                    //Once this issue is fixed this null check can be removed

                    if (tree != null)
                    {
                        GUI.Label(new Rect(0, 0, position.width, position.height), GUIContent.none, Styles.background);

                        HandleKeyboard();

                        if (tree.searchable)
                        {
                            LudiqGUI.Space(7);

                            if (letQueryClear)
                            {
                                letQueryClear = false;
                            }
                            else
                            {
                                EditorGUI.FocusTextInControl(searchFieldName);
                            }

                            var searchFieldPosition = GUILayoutUtility.GetRect(10, Styles.searchFieldHeight);
                            searchFieldPosition.x     += 8;
                            searchFieldPosition.width -= 16;

                            var newQuery = OnSearchGUI(searchFieldPosition, delayedQuery ?? query);

                            if (newQuery != query || delayedQuery != null)
                            {
                                if (!isAnimating)
                                {
                                    query = delayedQuery ?? newQuery;
                                    Search();
                                    delayedQuery = null;
                                }
                                else
                                {
                                    delayedQuery = newQuery;
                                }
                            }
                        }

                        OnLevelGUI(anim, GetLevelRelative(0), GetLevelRelative(-1));

                        if (anim < 1)
                        {
                            OnLevelGUI(anim + 1, GetLevelRelative(-1), GetLevelRelative(-2));
                        }

                        if (!activeParent.isLoading)
                        {
                            if (tree.searchable && hasSearch && !hasSufficientSearch)
                            {
                                EditorGUI.LabelField
                                (
                                    new Rect(0, 0, position.width, position.height),
                                    $"Enter at least {minSearchLength} characters to search.",
                                    Styles.insufficientSearch
                                );
                            }

                            if (activeNode != null && activeNode.option.hasFooter)
                            {
                                OnFooterGUI();
                            }
                        }

                        if (isAnimating && e.type == EventType.Repaint)
                        {
                            anim = Mathf.MoveTowards(anim, animTarget, repaintDeltaTime * animationSpeed);

                            if (animTarget == 0 && anim == 0)
                            {
                                anim       = 1;
                                animTarget = 1;
                                stack.Pop();
                            }

                            Repaint();
                        }

                        if (e.type == EventType.Repaint)
                        {
                            lastRepaintTime = DateTime.Now;
                        }

                        OnPositioning();
                    }
                }
            }
            catch (ArgumentException ex)
            {
                if (tree.multithreaded && ex.Message.StartsWith("Getting control "))
                {
                    // A bunch of happens that might affect the GUI could happen on a
                    // secondary thread, leading to Unity complaining about the amount
                    // of controls changing between the draw call and the layout call.
                    // Because these are hamless and last just one frame, we can safely
                    // ignore them and repaint right away.
                    requireRepaint = true;
                }
                else
                {
                    throw;
                }
            }
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var text = "Choose the assemblies in which you want to look for units.\n"
                       + "By default, all project and Unity assemblies are included.\n"
                       + "Unless you use a third-party plugin distributed as a DLL, you shouldn't need to change this.";

            GUILayout.Label(text, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            var height = LudiqGUI.GetInspectorHeight(null, assemblyOptionsMetadata, Styles.optionsWidth, GUIContent.none);

            LudiqGUI.BeginHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

            LudiqGUI.Inspector(assemblyOptionsMetadata, position, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                assemblyOptionsMetadata.Save();
                Codebase.UpdateSettings();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
            {
                assemblyOptionsMetadata.Reset(true);
                assemblyOptionsMetadata.Save();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
        private void OnOptionsGUI(FuzzyOptionNode parent, float scrollViewHeight)
        {
            if (parent.isLoading || (tree.showBackgroundWorkerProgress && BackgroundWorker.hasProgress))
            {
                LudiqGUI.BeginVertical();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.LoaderLayout();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();

                LudiqGUI.Space(16);
                LudiqGUI.BeginHorizontal();
                LudiqGUI.Space(10);
                var progressBarPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(19), GUILayout.ExpandWidth(true));
                if (tree.showBackgroundWorkerProgress && BackgroundWorker.hasProgress)
                {
                    EditorGUI.ProgressBar(progressBarPosition, BackgroundWorker.progressProportion, BackgroundWorker.progressLabel);
                }
                else if (showProgress)
                {
                    EditorGUI.ProgressBar(progressBarPosition, progress, progressText);
                }
                LudiqGUI.Space(10);
                LudiqGUI.EndHorizontal();

                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndVertical();
                Repaint();
                return;
            }

            parent.scroll = GUILayout.BeginScrollView(parent.scroll);

            EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

            var selectedOptionPosition = default(Rect);

            if (e.type == EventType.Repaint)
            {
                minOptionWidth = 0;
            }

            foreach (var node in parent.children)
            {
                node.EnsureDrawable();

                minOptionWidth = Mathf.Max(minOptionWidth, Mathf.Min(node.width, Styles.maxOptionWidth));
            }

            for (var i = 0; i < parent.children.Count; i++)
            {
                var node = parent.children[i];

                var optionPosition = GUILayoutUtility.GetRect(IconSize.Small, Styles.optionHeight, GUILayout.ExpandWidth(true));

                if (((e.type == EventType.MouseMove && GUIUtility.GUIToScreenPoint(e.mousePosition) != lastMouseMovePosition) || e.type == EventType.MouseDown) &&
                    parent.selectedIndex != i &&
                    optionPosition.Contains(e.mousePosition))
                {
                    parent.selectedIndex = i;
                    Repaint();
                    lastMouseMovePosition = GUIUtility.GUIToScreenPoint(e.mousePosition);
                }

                var optionIsSelected = false;

                if (i == parent.selectedIndex)
                {
                    optionIsSelected       = true;
                    selectedOptionPosition = optionPosition;
                }

                // Clipping
                if (optionPosition.yMax < parent.scroll.y || optionPosition.yMin > parent.scroll.y + scrollViewHeight)
                {
                    continue;
                }

                if (e.type == EventType.Repaint)
                {
                    node.style.Draw(optionPosition, node.label, false, false, optionIsSelected, optionIsSelected);
                }

                var right = optionPosition.xMax;

                if (node.hasChildren)
                {
                    right -= 13;
                    var rightArrowPosition = new Rect(right, optionPosition.y + 4, 13, 13);

                    if (e.type == EventType.Repaint)
                    {
                        Styles.rightArrow.Draw(rightArrowPosition, false, false, false, false);
                    }
                }

                if (!node.hasChildren && tree.selected.Contains(node.option.value))
                {
                    right -= 16;
                    var checkPosition = new Rect(right, optionPosition.y + 4, 12, 12);

                    if (e.type == EventType.Repaint)
                    {
                        Styles.check.Draw(checkPosition, false, false, false, false);
                    }
                }

                if (tree.favorites != null && tree.CanFavorite(node.option.value) && (optionIsSelected || tree.favorites.Contains(node.option.value)))
                {
                    right -= 19;
                    var starPosition = new Rect(right, optionPosition.y + 2, IconSize.Small, IconSize.Small);

                    EditorGUI.BeginChangeCheck();

                    var isFavorite = tree.favorites.Contains(node.option.value);

                    isFavorite = GUI.Toggle(starPosition, isFavorite, GUIContent.none, Styles.star);

                    if (EditorGUI.EndChangeCheck())
                    {
                        if (isFavorite)
                        {
                            tree.favorites.Add(node.option.value);
                        }
                        else
                        {
                            tree.favorites.Remove(node.option.value);
                        }

                        tree.OnFavoritesChange();

                        UpdateFavorites();
                    }
                }

                if (e.type == EventType.MouseDown && e.button == (int)MouseButton.Left && optionPosition.Contains(e.mousePosition))
                {
                    e.Use();
                    parent.selectedIndex = i;
                    SelectChild(node);
                }
            }

            EditorGUIUtility.SetIconSize(default(Vector2));

            GUILayout.EndScrollView();

            if (scrollToSelected && e.type == EventType.Repaint)
            {
                scrollToSelected = false;

                var lastRect = GUILayoutUtility.GetLastRect();

                if (selectedOptionPosition.yMax - lastRect.height > parent.scroll.y)
                {
                    var scroll = parent.scroll;
                    scroll.y      = selectedOptionPosition.yMax - lastRect.height;
                    parent.scroll = scroll;
                    Repaint();
                }

                if (selectedOptionPosition.y < parent.scroll.y)
                {
                    var scroll = parent.scroll;
                    scroll.y      = selectedOptionPosition.y;
                    parent.scroll = scroll;
                    Repaint();
                }
            }
        }
Beispiel #30
0
        private void OnGUI()
        {
            if (!isValid)
            {
                Close();
                return;
            }

            try
            {
                lock (guiLock)
                {
                    if (alpha < 1 && e.type == EventType.Repaint)
                    {
                        ReadTransparentBackground();
                        var innerPosition = new Rect(0, 0, position.width, position.height);
                        GUI.DrawTexture(innerPosition, transparentBackground);
                        GUI.DrawTexture(innerPosition, ColorPalette.unityBackgroundDark.WithAlpha(alpha).GetPixel());
                    }

                    LudiqGUI.color.BeginOverride(Color.white.WithAlpha(alpha));

                    GUI.Label(new Rect(0, 0, position.width, position.height), GUIContent.none, Styles.background);

                    HandleKeyboard();

                    if (tree.searchable)
                    {
                        LudiqGUI.Space(7);

                        if (letQueryClear)
                        {
                            letQueryClear = false;
                        }
                        else
                        {
                            EditorGUI.FocusTextInControl(searchFieldName);
                        }

                        var searchFieldPosition = GUILayoutUtility.GetRect(10, LudiqStyles.searchFieldInnerHeight);
                        searchFieldPosition.x     += 8;
                        searchFieldPosition.width -= 16;

                        var newQuery = OnSearchGUI(searchFieldPosition, delayedQuery ?? query);

                        if (newQuery != query || delayedQuery != null)
                        {
                            if (!isAnimating)
                            {
                                query = delayedQuery ?? newQuery;
                                Search();
                                delayedQuery = null;
                            }
                            else
                            {
                                delayedQuery = newQuery;
                            }
                        }

                        LudiqGUI.Space(5);
                    }

                    OnLevelGUI(anim);

                    prevAnim = anim;

                    if (isAnimating && e.type == EventType.Repaint)
                    {
                        anim = Mathf.MoveTowards(anim, animTarget, repaintDeltaTime * animationSpeed);

                        if (animTarget == 0 && anim == 0 && animAncestor != null)
                        {
                            while (stack.Count > 1 && stack[stack.Count - 1] != animAncestor)
                            {
                                stack.RemoveAt(stack.Count - 1);
                            }

                            anim         = 1;
                            prevAnim     = 1;
                            animTarget   = 1;
                            animAncestor = null;
                        }

                        Repaint();
                    }

                    if (e.type == EventType.Repaint)
                    {
                        lastRepaintTime = DateTime.UtcNow;
                    }

                    if (!activeParent.isLoading)
                    {
                        if (tree.searchable && hasSearch && activeParent.hasChildren == false)
                        {
                            var searchNotFoundLabel = new GUIContent(string.Format(searchNotFoundFormat, query));

                            minOptionWidth = Styles.searchNotFound.CalcSize(searchNotFoundLabel).x;

                            EditorGUI.LabelField
                            (
                                GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)),
                                searchNotFoundLabel,
                                Styles.searchNotFound
                            );
                        }

                        if (activeNode != null && activeNode.option.hasFooter)
                        {
                            OnFooterGUI();
                        }
                    }

                    LudiqGUI.color.EndOverride();

                    if (previousActiveNode != activeNode)
                    {
                        previousActiveNode?.option.OnFocusLeave(previousActiveNode);
                        activeNode?.option?.OnFocusEnter(activeNode);
                    }

                    previousActiveNode = activeNode;

                    OnPositioning();
                }
            }
            catch (ArgumentException ex)
            {
                if (tree.multithreaded && ex.Message.StartsWith("Getting control "))
                {
                    // A bunch of happens that might affect the GUI could happen on a
                    // secondary thread, leading to Unity complaining about the amount
                    // of controls changing between the draw call and the layout call.
                    // Because these are hamless and last just one frame, we can safely
                    // ignore them and repaint right away.
                    requireRepaint = true;
                }
                else
                {
                    throw;
                }
            }

            if (requireRepaint)
            {
                Repaint();
                requireRepaint = false;
            }
        }