Beispiel #1
0
        public override void    OnGUI()
        {
            if (this.button == null)
            {
                this.button = new GUIStyle(GUI.skin.button);
            }

            float w = this.button.CalcSize(this.content).x;

            if (this.image == null)
            {
                this.button.padding.left = GUI.skin.button.padding.left;
            }
            else
            {
                this.button.padding.left = (int)this.hub.height;
                w += 12F;                 // Remove texture width, because Button calculates using the whole height.
            }

            Rect r = GUILayoutUtility.GetRect(w, this.hub.height, GUI.skin.button);

            if (Event.current.type == EventType.MouseDrag &&
                Utility.position2D != Vector2.zero &&
                DragAndDrop.GetGenericData(Utility.DragObjectDataName) != null &&
                (Utility.position2D - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance)
            {
                Utility.position2D = Vector2.zero;
                DragAndDrop.StartDrag("Drag Object");
                Event.current.Use();
            }
            else if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true)
            {
                NGEditorGUILayout.PingObject(asset);

                Utility.position2D = Event.current.mousePosition;
                DragAndDrop.PrepareStartDrag();
                DragAndDrop.objectReferences = new Object[] { this.asset };
                DragAndDrop.SetGenericData(Utility.DragObjectDataName, 1);
            }

            GUI.Button(r, this.content, this.button);
            if (this.image != null)
            {
                r       = GUILayoutUtility.GetLastRect();
                r.x    += 4F;
                r.width = r.height;
                GUI.DrawTexture(r, this.image);
            }
        }
Beispiel #2
0
        protected virtual void  OnGUI()
        {
            FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGRenamerWindow.FreeAdContent);

            float halfWidth = this.position.width * .5F - 25F;

            this.errorPopup.OnGUILayout();

            for (int i = 0; i < this.filters.Count; i++)
            {
                EditorGUI.BeginDisabledGroup(NGLicensesManager.Check(i < NGRenamerWindow.MaxRenamerFilters, NGAssemblyInfo.Name + " Pro") == false);
                this.filters[i].OnHeaderGUI();
                if (this.filters[i].open == true)
                {
                    try
                    {
                        this.filters[i].OnGUI();
                    }
                    catch (Exception ex)
                    {
                        this.errorPopup.exception = ex;
                    }
                }
                EditorGUI.EndDisabledGroup();
            }

            if (this.objects.Count > 0 || this.paths.Count > 0 || Selection.activeObject != null)
            {
                using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                {
                    if (GUILayout.Button("Replace All") == true)
                    {
                        this.ReplaceAll();
                    }
                }

                if (this.objects.Count > 0)
                {
                    EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                    {
                        GUILayout.Label("Assets (" + this.objects.Count + ")", GeneralStyles.Title1);
                    }
                    EditorGUILayout.EndHorizontal();

                    this.assetsScrollPosition = EditorGUILayout.BeginScrollView(this.assetsScrollPosition, GUILayoutOptionPool.ExpandHeightTrue);
                    {
                        for (int i = 0; i < this.objects.Count; i++)
                        {
                            NGRenamerWindow.drawingIndex = i;

                            EditorGUILayout.BeginHorizontal();
                            {
                                Texture2D icon = Utility.GetIcon(this.objects[i].GetInstanceID());

                                Rect r = GUILayoutUtility.GetRect(16F, 16F);
                                GUI.DrawTexture(r, icon);
                                r.width += halfWidth - 32F;
                                if (GUI.Button(r, "", GUI.skin.label) == true)
                                {
                                    NGEditorGUILayout.PingObject(this.objects[i]);
                                    return;
                                }

                                this.DrawElement(Path.GetFileName(this.objects[i].name), halfWidth - 32F, (s) => this.RenameAsset(this.objects[i], s));

                                if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton) == true)
                                {
                                    this.objects.RemoveAt(i);
                                    return;
                                }
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    EditorGUILayout.EndScrollView();

                    GUILayout.Space(5F);
                }

                for (int i = 0; i < this.paths.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                    {
                        Rect r = GUILayoutUtility.GetRect(0F, 24F, GUILayoutOptionPool.ExpandWidthTrue);
                        GUI.Label(r, "Path " + this.paths[i].path + " (" + (this.paths[i].directories.Length + this.paths[i].files.Length) + ")", GeneralStyles.Title1);

                        Utility.content.text    = "↻";
                        Utility.content.tooltip = "Refresh folder's content";
                        if (GUILayout.Button(Utility.content, GeneralStyles.ToolbarAltButton, GUILayoutOptionPool.Width(20F)) == true)
                        {
                            try
                            {
                                this.paths[i].Update();
                            }
                            catch (Exception ex)
                            {
                                this.errorPopup.exception = ex;
                            }
                            return;
                        }
                        Utility.content.tooltip = string.Empty;

                        if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton, GUILayoutOptionPool.Width(20F)) == true)
                        {
                            this.paths.RemoveAt(i);
                            return;
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    try
                    {
                        this.paths[i].scrollPosition = EditorGUILayout.BeginScrollView(this.paths[i].scrollPosition, GUILayoutOptionPool.ExpandHeightTrue);
                        {
                            for (int j = 0; j < this.paths[i].directories.Length; j++)
                            {
                                NGRenamerWindow.drawingIndex = j;

                                this.DrawElement(Path.GetFileName(this.paths[i].directories[j]), halfWidth, (s) => {
                                    try
                                    {
                                        // To ensure different letter case will work.
                                        string tmp = Path.Combine(this.paths[i].path, Path.GetRandomFileName());
                                        Directory.Move(this.paths[i].absolutePathDirectories[j], tmp);
                                        Directory.Move(tmp, Path.Combine(this.paths[i].path, s));
                                        this.paths[i].directories[j] = s;
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.LogException(ex);
                                    }
                                });
                            }

                            for (int j = 0; j < this.paths[i].files.Length; j++)
                            {
                                NGRenamerWindow.drawingIndex = j;

                                this.DrawElement(Path.GetFileName(this.paths[i].files[j]), halfWidth, (s) => {
                                    try
                                    {
                                        File.Move(this.paths[i].absolutePathFiles[j], Path.Combine(this.paths[i].path, s));
                                        this.paths[i].files[j] = s;
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.LogException(ex);
                                    }
                                });
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    catch (Exception ex)
                    {
                        this.paths.RemoveAt(i);
                        Debug.LogException(ex);
                    }

                    GUILayout.Space(5F);
                }

                if (Selection.objects.Length > 0)
                {
                    EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                    {
                        GUILayout.Label("Selection", GeneralStyles.Title1);
                    }
                    EditorGUILayout.EndHorizontal();

                    this.selectionScrollPosition = EditorGUILayout.BeginScrollView(this.selectionScrollPosition, GUILayoutOptionPool.ExpandHeightTrue);
                    {
                        for (int i = 0; i < Selection.objects.Length; i++)
                        {
                            NGRenamerWindow.drawingIndex = i;

                            this.DrawElement(Selection.objects[i].name, halfWidth, (s) => this.RenameAsset(Selection.objects[i], s));
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }

                using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                {
                    if (GUILayout.Button("Replace All") == true)
                    {
                        this.ReplaceAll();
                    }
                }

                GUILayout.FlexibleSpace();
            }
            else
            {
                Rect r = GUILayoutUtility.GetRect(this.position.width, 16F, GUILayoutOptionPool.ExpandHeightTrue);

                r.x      += 2F;
                r.y      += 2F;
                r.width  -= 4F;
                r.height -= 4F;

                if (Event.current.type == EventType.Repaint)
                {
                    Utility.DrawUnfillRect(r, Color.grey);
                }

                GUI.Label(r, "Select assets from Hierarchy or Project\n\nDrop any files or folders from\n" + (Application.platform == RuntimePlatform.WindowsEditor ? "Explorer, " : (Application.platform == RuntimePlatform.OSXEditor ? "Finder, " : "")) + "Hierarchy or Project", GeneralStyles.CenterText);
            }

            if (Event.current.type == EventType.DragUpdated)
            {
                if (DragAndDrop.objectReferences.Length > 0 || DragAndDrop.paths.Length > 0)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                }
                else
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                }
            }
            else if (Event.current.type == EventType.DragPerform)
            {
                DragAndDrop.AcceptDrag();

                try
                {
                    if (DragAndDrop.objectReferences.Length > 0)
                    {
                        for (int i = 0; i < DragAndDrop.objectReferences.Length; i++)
                        {
                            Object obj = DragAndDrop.objectReferences[i];

                            if (typeof(Behaviour).IsAssignableFrom(obj.GetType()) == true)
                            {
                                obj = (obj as Behaviour).gameObject;
                            }

                            if (this.objects.Contains(obj) == false)
                            {
                                this.objects.Add(obj);
                            }
                        }
                    }
                    else if (DragAndDrop.paths.Length > 0)
                    {
                        for (int i = 0; i < DragAndDrop.paths.Length; i++)
                        {
                            string path = DragAndDrop.paths[i];
                            if (Directory.Exists(path) == false)
                            {
                                path = new DirectoryInfo(path).Parent.FullName;
                            }

                            if (string.IsNullOrEmpty(path) == false && this.paths.Exists((p) => p.path == path) == false)
                            {
                                this.paths.Add(new PathFiles(path));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.errorPopup.exception = ex;
                }

                Event.current.Use();
            }
            else if (Event.current.type == EventType.Repaint && DragAndDrop.visualMode == DragAndDropVisualMode.Move)
            {
                Utility.DropZone(new Rect(0F, 0F, this.position.width, this.position.height), "Drop folder or asset to rename");
            }

            FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro");
        }
Beispiel #3
0
        private void    DrawComponent(ComponentContainer container)
        {
            Editor e = Editor.CreateEditor(container.component);

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(2F);

                Rect r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(20F));

                GUI.DrawTexture(r, container.gameObjectIcon);

                NGEditorGUILayout.PingObject(container.component.name, container.component.gameObject, GUILayoutOptionPool.Height(16F));

                container.useDefaultEditor = GUILayout.Toggle(container.useDefaultEditor, new GUIContent("No Custom Editor", "Use default editor."), GeneralStyles.ToolbarToggle, GUILayoutOptionPool.ExpandWidthFalse);
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(4F);

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(2F);

                Rect r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(20F));

                if (container.componentIcons[container.workingComponentIndex] != null)
                {
                    GUI.DrawTexture(r, container.componentIcons[container.workingComponentIndex]);
                }

                GUILayout.Space(5F);

                r = GUILayoutUtility.GetRect(0F, 16F, GUILayoutOptionPool.Width(16F));

                int enabled = EditorUtility.GetObjectEnabled(container.component);
                if (enabled != -1)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.Toggle(r, enabled == 1);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        EditorUtility.SetObjectEnabled(container.component, enabled != 1);
                    }
                }

                EditorGUI.BeginChangeCheck();
                int n = EditorGUILayout.Popup(container.workingComponentIndex, container.componentNames);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    Component[] components = container.component.gameObject.GetComponents <Component>();

                    if (n < components.Length)
                    {
                        container.Init(components[n]);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            // Exception for Transform, its Editor messes the GUI up.
            if (container.useDefaultEditor == true || container.component is Transform)
            {
                e.DrawDefaultInspector();
            }
            else
            {
                e.OnInspectorGUI();
            }
        }
        protected virtual void  OnGUI()
        {
            FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGShaderFinderWindow.FreeAdContent);

            Rect r = this.position;

            r.x      = 0F;
            r.y      = 0F;
            r.height = NGShaderFinderWindow.SearchButtonHeight;

            EditorGUI.BeginDisabledGroup(this.isSearching);
            {
                r.height = Constants.SingleLineHeight;
                using (LabelWidthRestorer.Get(100F))
                {
                    r.width = this.position.width - NGShaderFinderWindow.FindButtonWidth - NGShaderFinderWindow.FindButtonLeftSpacing;
                    EditorGUI.BeginChangeCheck();
                    Shader newTarget = EditorGUI.ObjectField(r, "Find Shader", this.targetShader, typeof(Shader), false) as Shader;
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        this.targetShader = newTarget;
                    }
                }
                r.y += r.height + NGShaderFinderWindow.Spacing;

                r.width         = NGShaderFinderWindow.TargetReplaceLabelWidth;
                this.canReplace = GUI.Toggle(r, this.canReplace, "Replace With");
                r.x            += r.width;

                EditorGUI.BeginDisabledGroup(!this.canReplace);
                {
                    r.width            = this.position.width - r.x - NGShaderFinderWindow.SwitchShaderButtonWidth - NGShaderFinderWindow.FindButtonWidth - NGShaderFinderWindow.FindButtonLeftSpacing;
                    this.replaceShader = EditorGUI.ObjectField(r, this.replaceShader, typeof(Shader), false) as Shader;
                }
                EditorGUI.EndDisabledGroup();

                r.x    += r.width;
                r.width = NGShaderFinderWindow.SwitchShaderButtonWidth;
                if (GUI.Button(r, "⇅", GeneralStyles.BigFontToolbarButton) == true)
                {
                    Shader tmp = this.replaceShader;
                    this.replaceShader = this.targetShader;
                    this.targetShader  = tmp;
                }

                r.yMin -= r.height + NGShaderFinderWindow.Spacing;
                r.width = NGShaderFinderWindow.FindButtonWidth;
                r.x     = this.position.width - NGShaderFinderWindow.FindButtonWidth;

                EditorGUI.BeginDisabledGroup(this.targetShader == null || this.isSearching == true);
                {
                    using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                    {
                        if (GUI.Button(r, "Find") == true)
                        {
                            this.FindReferences();
                        }
                    }
                }
                EditorGUI.EndDisabledGroup();

                r.y += r.height + NGShaderFinderWindow.Spacing;
            }
            EditorGUI.EndDisabledGroup();

            if (this.canReplace == true)
            {
                EditorGUI.BeginDisabledGroup(this.isSearching == true || this.hasResult == false);
                {
                    using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                    {
                        r.x     = 0F;
                        r.width = this.position.width * .5F;
                        if (GUI.Button(r, "Replace") == true)
                        {
                            this.ReplaceReferences(true);
                        }
                        r.x += r.width;

                        if (GUI.Button(r, "Set all") == true)
                        {
                            this.ReplaceReferences(false);
                        }
                        r.y += r.height + NGShaderFinderWindow.Spacing + NGShaderFinderWindow.Spacing;
                    }
                }
                EditorGUI.EndDisabledGroup();
            }

            r.x     = 0F;
            r.width = this.position.width;

            if (this.hasResult == true)
            {
                r.height = Constants.SingleLineHeight;
                GUI.Box(r, string.Empty, GeneralStyles.Toolbar);
                GUI.Label(r, this.resultsHeaderLabel);

                using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton))
                {
                    r.xMin = r.xMax - NGShaderFinderWindow.ClearButtonWidth;
                    if (GUI.Button(r, "Clear", GeneralStyles.ToolbarButton) == true)
                    {
                        this.ClearResults();
                    }
                }
                r.y += r.height + NGShaderFinderWindow.Spacing;

                r.x     = 0F;
                r.width = this.position.width;

                Rect bodyRect = r;
                bodyRect.height = this.position.height - r.y;

                Rect viewRect = new Rect(0F, 0F, 0F, (Constants.SingleLineHeight + NGShaderFinderWindow.Spacing) * this.results.Count - NGShaderFinderWindow.Spacing);

                this.scrollPosition = GUI.BeginScrollView(bodyRect, this.scrollPosition, viewRect);
                {
                    float w = r.width - (viewRect.height > bodyRect.height ? 16F : 0F);

                    r.y      = 0F;
                    r.height = Constants.SingleLineHeight;

                    for (int i = 0; i < this.results.Count; i++)
                    {
                        if (r.y + r.height + NGShaderFinderWindow.Spacing <= this.scrollPosition.y)
                        {
                            r.y += r.height + NGShaderFinderWindow.Spacing;
                            continue;
                        }

                        r.x     = 0F;
                        r.width = w - NGShaderFinderWindow.PingButtonWidth;

                        EditorGUI.BeginChangeCheck();
                        Shader o = EditorGUI.ObjectField(r, this.resultsName[i], this.results[i].shader, typeof(Shader), false) as Shader;
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            Undo.RecordObject(this.results[i], "Replace Material shader");
                            this.results[i].shader = o;
                            EditorUtility.SetDirty(this.results[i]);
                        }

                        r.x    += r.width;
                        r.width = NGShaderFinderWindow.PingButtonWidth;
                        NGEditorGUILayout.PingObject(r, LC.G("Ping"), this.results[i]);
                        r.y += r.height + NGShaderFinderWindow.Spacing;

                        if (r.y - this.scrollPosition.y > bodyRect.height)
                        {
                            break;
                        }
                    }
                }
                GUI.EndScrollView();
            }

            FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro");
        }
Beispiel #5
0
        private void    DrawRecovery()
        {
            if (this.currentGameObject >= this.missings.Count)
            {
                EditorGUILayout.HelpBox("Recovery finished.", MessageType.Info);
                return;
            }

            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            {
                if (GUILayout.Button((this.currentGameObject + 1) + " / " + this.missings.Count + " ☰", "GV Gizmo DropDown", GUILayoutOptionPool.ExpandWidthFalse) == true)
                {
                    GenericMenu menu = new GenericMenu();

                    for (int i = 0; i < this.missings.Count; i++)
                    {
                        menu.AddItem(new GUIContent(this.missings[i].path), false, (n) => this.currentGameObject = (int)n, i);
                    }

                    menu.ShowAsContext();
                }

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Stop", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(100F)) == true)
                {
                    this.isRecovering = false;
                    this.tab          = Tab.Project;
                    return;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            {
                EditorGUI.BeginDisabledGroup(this.currentGameObject <= 0);
                {
                    if (GUILayout.Button("<<", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(50F)) == true)
                    {
                        --this.currentGameObject;
                        this.isPausing = false;
                        this.skipFix   = true;
                    }
                }
                EditorGUI.EndDisabledGroup();

                NGEditorGUILayout.PingObject(this.missings[this.currentGameObject].path, this.missings[this.currentGameObject].gameObject, GeneralStyles.ToolbarButton);

                EditorGUI.BeginDisabledGroup(this.currentGameObject >= this.missings.Count - 1);
                {
                    if (GUILayout.Button(">>", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(50F)) == true)
                    {
                        ++this.currentGameObject;
                        this.isPausing = false;
                        this.skipFix   = true;
                    }

                    if (GUILayout.Button("Skip", GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(100F)) == true)
                    {
                        ++this.currentGameObject;
                        this.isPausing = false;
                    }
                }
                EditorGUI.EndDisabledGroup();
            }
            EditorGUILayout.EndHorizontal();

            this.PostDiagnostic        += this.OnPostDiagnosticManualRecovery;
            this.scrollPositionRecovery = EditorGUILayout.BeginScrollView(this.scrollPositionRecovery);
            {
                for (int i = 0; i < this.rawComponents.Count; i++)
                {
                    this.rawComponents[i].Draw(this);
                }
            }
            EditorGUILayout.EndScrollView();
            this.PostDiagnostic -= this.OnPostDiagnosticManualRecovery;
        }
Beispiel #6
0
        private void    DrawProject()
        {
            GUILayout.Space(5F);

            EditorGUILayout.BeginVertical("ButtonLeft");
            {
                this.openAutoRecovery = EditorGUILayout.Foldout(this.openAutoRecovery, "Recovery Settings (" + Enum.GetName(typeof(RecoveryMode), this.recoveryMode) + ")");

                if (this.openAutoRecovery == true)
                {
                    this.recoveryMode = (RecoveryMode)EditorGUILayout.EnumPopup("Recovery Mode", this.recoveryMode);

                    if (this.recoveryMode == RecoveryMode.Automatic)
                    {
                        this.promptOnPause       = EditorGUILayout.Toggle(this.promptOnPauseContent, this.promptOnPause);
                        this.useCache            = EditorGUILayout.Toggle(this.useCacheContent, this.useCache);
                        this.supaFast            = EditorGUILayout.Toggle(supaFastContent, this.supaFast);
                        this.recoveryLogFilePath = NGEditorGUILayout.SaveFileField("Recovery Log File", this.recoveryLogFilePath);
                    }

                    GUILayout.Space(5F);
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                {
                    if (GUILayout.Button("Scan", GeneralStyles.BigButton) == true)
                    {
                        string[] assets = AssetDatabase.GetAllAssetPaths();

                        this.hasResult       = true;
                        this.selectedMissing = -1;
                        this.missings.Clear();

                        try
                        {
                            for (int i = 0; i < assets.Length; i++)
                            {
                                if (assets[i].EndsWith(".prefab") == false)
                                {
                                    continue;
                                }

                                if (EditorUtility.DisplayCancelableProgressBar(NGMissingScriptRecoveryWindow.NormalTitle, "Scanning " + assets[i], (float)i / (float)assets.Length) == true)
                                {
                                    break;
                                }

                                Object[] content = AssetDatabase.LoadAllAssetsAtPath(assets[i]);

                                for (int j = 0; j < content.Length; j++)
                                {
                                    GameObject go = content[j] as GameObject;

                                    if (go != null)
                                    {
                                        Component[] components = go.GetComponents <Component>();

                                        for (int k = 0; k < components.Length; k++)
                                        {
                                            if (components[k] == null)
                                            {
                                                this.missings.Add(new MissingGameObject(go));
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        finally
                        {
                            EditorUtility.ClearProgressBar();
                        }

                        return;
                    }
                }

                GUILayout.FlexibleSpace();

                if (this.cachedComponentFixes.Count > 0)
                {
                    if (GUILayout.Button("Clear Recovery Cache (" + this.cachedComponentFixes.Count + " elements)", GeneralStyles.BigButton) == true)
                    {
                        this.cachedComponentFixes.Clear();
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            if (this.hasResult == true)
            {
                EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                {
                    GUILayout.Label("Result");

                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("X", GeneralStyles.ToolbarCloseButton) == true)
                    {
                        this.hasResult = false;
                    }
                }
                EditorGUILayout.EndHorizontal();

                if (this.missings.Count == 0)
                {
                    GUILayout.Label("No missing script found.");
                }
                else
                {
                    this.scrollPositionResult = EditorGUILayout.BeginScrollView(this.scrollPositionResult);
                    {
                        for (int i = 0; i < this.missings.Count; i++)
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                NGEditorGUILayout.PingObject(this.missings[i].path, this.missings[i].gameObject, GeneralStyles.LeftButton);

                                if (GUILayout.Button("Fix", GUILayoutOptionPool.Width(75F)) == true)
                                {
                                    this.selectedMissing = i;
                                    this.tab             = 0;
                                    this.Diagnose(this.missings[i].gameObject);
                                }
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    EditorGUILayout.EndScrollView();

                    GUILayout.FlexibleSpace();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (this.recoveryMode == RecoveryMode.Automatic)
                        {
                            EditorGUILayout.HelpBox("Backup your project before\ndoing any automatic recovery.", MessageType.Warning);
                        }

                        using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton))
                        {
                            if (GUILayout.Button("Start Recovery", GeneralStyles.BigButton) == true)
                            {
                                Utility.StartBackgroundTask(this.RecoveryTask());
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
        }
Beispiel #7
0
        private void    DrawSelection()
        {
            if (Selection.activeGameObject != this.selectionTarget)
            {
                this.selectionTarget = Selection.activeGameObject;

                if (Selection.activeGameObject != null)
                {
                    this.Diagnose(Selection.activeGameObject);
                }
                else
                {
                    this.target = null;
                }
            }

            if (this.target == null)
            {
                if (this.selectionTarget == null)
                {
                    GUILayout.Label("Select a prefab (or an instance of it) to diagnose", GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue);
                }
                else
                {
                    GUILayout.Label("No diagnostic available", GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue);
                }
                return;
            }

            if (this.selectedMissing >= 0)
            {
                EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
                {
                    EditorGUI.BeginDisabledGroup(this.selectedMissing <= 0);
                    {
                        if (GUILayout.Button("<<", GeneralStyles.ToolbarButton, GUILayoutOptionPool.MaxWidth(100F)) == true)
                        {
                            --this.selectedMissing;
                            this.Diagnose(this.missings[this.selectedMissing].gameObject);
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    NGEditorGUILayout.PingObject(this.missings[this.selectedMissing].path, this.missings[this.selectedMissing].gameObject, GeneralStyles.ToolbarButton);

                    EditorGUI.BeginDisabledGroup(this.selectedMissing >= this.missings.Count - 1);
                    {
                        if (GUILayout.Button(">>", GeneralStyles.ToolbarButton, GUILayoutOptionPool.MaxWidth(100F)) == true)
                        {
                            ++this.selectedMissing;
                            this.Diagnose(this.missings[this.selectedMissing].gameObject);
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                Utility.content.text  = this.target.name;
                Utility.content.image = Utility.GetIcon(this.target.GetInstanceID());
                EditorGUILayout.LabelField(Utility.content);
                Utility.content.image = null;
            }

            this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition);
            {
                for (int i = 0; i < this.rawComponents.Count; i++)
                {
                    this.rawComponents[i].Draw(this);
                }
            }
            EditorGUILayout.EndScrollView();
        }