Esempio n. 1
0
        public override void    OnGUI()
        {
            if (this.buttonLeft == null)
            {
                this.buttonLeft  = "ButtonLeft";
                this.buttonRight = "ButtonRight";
            }

            EditorGUI.BeginDisabledGroup(!NGNavSelectionWindow.CanSelectPrevious);
            {
                if (GUILayout.Button(this.leftContent, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    NGNavSelectionWindow.SelectPreviousSelection();
                }
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!NGNavSelectionWindow.CanSelectNext);
            {
                if (GUILayout.Button(this.rightContent, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    NGNavSelectionWindow.SelectNextSelection();
                }
            }
            EditorGUI.EndDisabledGroup();
        }
Esempio n. 2
0
        private static void     OnGUIGeneralLog()
        {
            LogSettings settings = HQ.Settings.Get <LogSettings>();

            ConsoleSettingsEditor.generalLogScrollPosition = EditorGUILayout.BeginScrollView(ConsoleSettingsEditor.generalLogScrollPosition);
            {
                ConsoleSettingsEditor.sectionLog.OnGUI();

                GUILayout.Space(10F);
            }
            EditorGUILayout.EndScrollView();

            EditorGUILayout.BeginVertical(GUILayoutOptionPool.Height(16F + 5F * settings.height));
            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            EditorGUILayout.LabelField("Preview :");
            EditorGUILayout.EndHorizontal();

            ConsoleSettingsEditor.DrawRow(0, 0, false, "A selected row.", "");
            ConsoleSettingsEditor.DrawRow(1, 0, false, "A normal even row.", "1");
            ConsoleSettingsEditor.DrawRow(2, 1, false, "A warning odd row.", "23");
            ConsoleSettingsEditor.DrawRow(3, 2, false, "An error even row.", "456");
            ConsoleSettingsEditor.DrawRow(4, 3, false, "An exception odd row.", "7890");

            EditorGUILayout.EndVertical();
        }
Esempio n. 3
0
 public override void    OnGUI()
 {
     this.content.text  = (string.IsNullOrEmpty(this.alias) == true ? this.menuItem : this.alias);
     this.content.image = this.image;
     if (GUILayout.Button(this.content, GUILayoutOptionPool.Height(this.hub.height)) == true)
     {
         EditorApplication.ExecuteMenuItem(this.menuItem);
     }
 }
Esempio n. 4
0
        public override void    OnGUI()
        {
            if (this.buttonLeft == null)
            {
                this.buttonLeft  = "ButtonLeft";
                this.buttonRight = "ButtonRight";
            }

            if (this.displayOnlyIcon == true)
            {
                if (GUILayout.Button(this.unityModeIcon, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(24F)) == true)
                {
                    NGRemoteHierarchyWindow.FocusUnityWindows();
                }
                Rect r = GUILayoutUtility.GetLastRect();

                GUI.DrawTexture(r, this.unityModeIcon.image, ScaleMode.ScaleToFit);

                if (GUILayout.Button(this.remoteModeIcon, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(24F)) == true)
                {
                    foreach (NGRemoteHierarchyWindow window in Utility.EachEditorWindows(typeof(NGRemoteHierarchyWindow)))
                    {
                        window.Focus();
                    }

                    foreach (NGRemoteWindow window in Utility.EachEditorWindows(typeof(NGRemoteWindow)))
                    {
                        window.Focus();
                    }
                }

                r = GUILayoutUtility.GetLastRect();

                GUI.DrawTexture(r, this.remoteModeIcon.image, ScaleMode.ScaleToFit);
            }
            else
            {
                if (GUILayout.Button(this.unityMode, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    NGRemoteHierarchyWindow.FocusUnityWindows();
                }

                if (GUILayout.Button(this.remoteMode, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    foreach (NGRemoteHierarchyWindow window in Utility.EachEditorWindows(typeof(NGRemoteHierarchyWindow)))
                    {
                        window.Focus();
                    }

                    foreach (NGRemoteWindow window in Utility.EachEditorWindows(typeof(NGRemoteWindow)))
                    {
                        window.Focus();
                    }
                }
            }
        }
Esempio n. 5
0
        private static void     OnGUIGeneralStackTrace()
        {
            StackTraceSettings stackTraceSettings = HQ.Settings.Get <StackTraceSettings>();
            LogSettings        logSettings        = HQ.Settings.Get <LogSettings>();

            ConsoleSettingsEditor.generalStackTraceScrollPosition = EditorGUILayout.BeginScrollView(ConsoleSettingsEditor.generalStackTraceScrollPosition);
            {
                EditorGUI.BeginChangeCheck();
                ConsoleSettingsEditor.sectionStackTrace.OnGUI();
                if (EditorGUI.EndChangeCheck() == true)
                {
                    LogConditionParser.cachedFrames.Clear();
                    LogConditionParser.cachedFramesArrays.Clear();
                    MainModule.methodsCategories.Clear();
                }

                GUILayout.Space(10F);
            }
            EditorGUILayout.EndScrollView();

            EditorGUILayout.BeginVertical(GUILayoutOptionPool.Height(16F + 2 * logSettings.height + 8 * Constants.SingleLineHeight));
            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            EditorGUILayout.LabelField("Preview :");
            EditorGUILayout.EndHorizontal();

            if (stackTraceSettings.skipUnreachableFrame == true)
            {
                ConsoleSettingsEditor.DrawStackFrame(0, "Sub Frame.", "Assets/An/Existing/File.cs", true);
            }
            else
            {
                ConsoleSettingsEditor.DrawStackFrame(0, "Top Frame.", "A/File/Somewhere/That/Does/Not/Exist.cs", false);
                ConsoleSettingsEditor.DrawStackFrame(1, "Sub Frame.", "Assets/An/Existing/File.cs", true);
            }

            ConsoleSettingsEditor.DrawStackFrameCode(1, false, "using UnityEngine;");
            ConsoleSettingsEditor.DrawStackFrameCode(2, false, "private static class Foo : Object");
            ConsoleSettingsEditor.DrawStackFrameCode(3, false, "{");
            ConsoleSettingsEditor.DrawStackFrameCode(4, false, "	public internal void	Func(Vector2 v)");
            ConsoleSettingsEditor.DrawStackFrameCode(5, false, "	{");
            ConsoleSettingsEditor.DrawStackFrameCode(6, true, "		Debug.Log(\"Someting\");");
            ConsoleSettingsEditor.DrawStackFrameCode(7, false, "	}");
            ConsoleSettingsEditor.DrawStackFrameCode(8, false, "}");

            EditorGUILayout.EndVertical();
        }
Esempio n. 6
0
        protected virtual void  OnGUI()
        {
            Rect r = this.position;

            r.x     = 0F;
            r.y     = 0F;
            r.yMax -= 32F;
            this.drawer.OnGUI(r);

            r.y     += r.height;
            r.height = 32F;

            GUILayout.BeginArea(r);
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.BeginVertical();
                    {
                        GUILayout.Space(10F);
                        using (LabelWidthRestorer.Get(95F))
                        {
                            this.exportFile = NGEditorGUILayout.SaveFileField(LC.G("ExportFilePath"), this.exportFile, string.Empty, string.Empty);
                        }
                    }
                    EditorGUILayout.EndVertical();

                    GUILayout.Space(10F);

                    EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.exportFile));
                    {
                        using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton))
                        {
                            if (GUILayout.Button(LC.G("Export"), GUILayoutOptionPool.Height(30F)) == true)
                            {
                                this.ExportLogs();
                            }
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndHorizontal();
            }
            GUILayout.EndArea();
        }
        public override void    OnGUI()
        {
            using (ColorContentRestorer.Get(this.methodInfo == null, Color.red))
            {
                if (string.IsNullOrEmpty(this.alias) == false)
                {
                    this.content.text = this.alias;
                }
                else
                {
                    this.content.text = this.methodInfo != null ? this.methodInfo.Name : "Method Unknown";
                }

                if (GUILayout.Button(this.content, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    this.methodInfo.Invoke(null, null);
                }
            }
        }
Esempio n. 8
0
        protected virtual void  OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            this.input = EditorGUILayout.TextField("Type", this.input);
            if (EditorGUI.EndChangeCheck() == true && this.input.Length > 2)
            {
                Utility.RegisterIntervalCallback(this.RefreshMatchingTypes, 100, 1);
            }

            Type t = Type.GetType(this.input);

            if (t != null)
            {
                if (GUILayout.Button("Analyze " + t.FullName))
                {
                    this.membersEmbedded.Clear();
                    this.type       = t;
                    this.fields     = t.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                    this.properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
                    this.methods    = t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);

                    for (int i = 0; i < this.fields.Length; i++)
                    {
                        if (this.SkipMember(this.fields[i]) == false)
                        {
                            this.membersEmbedded.Add(this.fields[i]);
                        }
                    }
                    for (int i = 0; i < this.properties.Length; i++)
                    {
                        if (this.SkipMember(this.properties[i]) == false)
                        {
                            this.membersEmbedded.Add(this.properties[i]);
                        }
                    }
                    for (int i = 0; i < this.methods.Length; i++)
                    {
                        if (this.methods[i].Name == "Finalize" ||
                            this.methods[i].Name == "GetHashCode" ||
                            this.methods[i].Name == "GetType" ||
                            this.methods[i].Name == "MemberwiseClone" ||
                            this.methods[i].Name == "ToString")
                        {
                            continue;
                        }

                        if (this.SkipMember(this.methods[i]) == false)
                        {
                            this.membersEmbedded.Add(this.methods[i]);
                        }
                    }
                }
            }

            this.scrollPositionAQN = EditorGUILayout.BeginScrollView(this.scrollPositionAQN, GUILayoutOptionPool.Height(Mathf.Min(this.matchingTypes.Count * 18F, 200F)));
            {
                for (int i = 0; i < this.matchingTypes.Count; i++)
                {
                    if (GUILayout.Button(this.matchingTypes[i].FullName) == true)
                    {
                        this.input = this.matchingTypes[i].AssemblyQualifiedName;
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            this.scrollPositionMembers = EditorGUILayout.BeginScrollView(this.scrollPositionMembers);
            {
                if (this.type != null)
                {
                    if (string.IsNullOrEmpty(this.result) == false)
                    {
                        this.outputFilePath = NGEditorGUILayout.SaveFileField("File", this.outputFilePath);

                        if (GUILayout.Button("Write to file") == true)
                        {
                            File.WriteAllText(this.outputFilePath, this.result);
                        }

                        if (GUILayout.Button("Copy to clipboard") == true)
                        {
                            EditorGUIUtility.systemCopyBuffer = this.result;
                        }

                        if (this.result.Length < short.MaxValue / 2)
                        {
                            EditorGUILayout.TextArea(this.result, GUILayout.MaxHeight(150F));
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("Result is too big to display.", MessageType.Warning);
                        }
                    }

                    if (GUILayout.Button("Generate") == true)
                    {
                        this.Generate();
                    }

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("Fields (" + this.fields.Length + ")");
                    if (GUILayout.Button("Toggle") == true)
                    {
                        this.ToggleMembers(this.fields);
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    ++EditorGUI.indentLevel;
                    this.DrawMembers(this.fields);
                    --EditorGUI.indentLevel;

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("Properties (" + this.properties.Length + ")");
                    if (GUILayout.Button("Toggle") == true)
                    {
                        this.ToggleMembers(this.properties);
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    ++EditorGUI.indentLevel;
                    this.DrawMembers(this.properties);
                    --EditorGUI.indentLevel;


                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("Methods (" + this.methods.Length + ")");
                    if (GUILayout.Button("Toggle") == true)
                    {
                        this.ToggleMembers(this.methods);
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    ++EditorGUI.indentLevel;
                    this.DrawMembers(this.methods);
                    --EditorGUI.indentLevel;
                }
            }
            EditorGUILayout.EndScrollView();
        }
Esempio n. 9
0
        protected virtual void  OnGUI()
        {
            InternalNGDebug.AssertFile(this.hierarchy != null, "ResourcesPicker requires to be created through ResourcesPicker.Init.");

            if (this.resources == null)
            {
                this.hierarchy.GetResources(this.type, out this.resources, out this.ids);

                if (this.resources == null)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(GeneralStyles.StatusWheel, GUILayoutOptionPool.Width(20F));
                        EditorGUILayout.LabelField(LC.G("NGHierarchy_ResourcesNotAvailable"), GeneralStyles.WrapLabel);
                        GUILayout.FlexibleSpace();
                    }
                    EditorGUILayout.EndHorizontal();

                    return;
                }
                else
                {
                    for (int i = 0; i < this.ids.Length; i++)
                    {
                        if (this.ids[i] == this.initialInstanceID)
                        {
                            this.FitFocusedRowInScreen(i);
                            break;
                        }
                    }
                }
            }

            if (Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == KeyCode.UpArrow)
                {
                    this.selectedInstanceID = this.GetInstanceIDNeighbour(this.selectedInstanceID, -1);
                    this.SendSelection(this.selectedInstanceID);
                    this.Repaint();
                }
                else if (Event.current.keyCode == KeyCode.DownArrow)
                {
                    this.selectedInstanceID = this.GetInstanceIDNeighbour(this.selectedInstanceID, 1);
                    this.SendSelection(this.selectedInstanceID);
                    this.Repaint();
                }
                else if (Event.current.keyCode == KeyCode.PageUp)
                {
                    this.selectedInstanceID = this.GetInstanceIDNeighbour(this.selectedInstanceID, -(Mathf.FloorToInt((this.position.height - (ResourcesPickerWindow.HeaderHeight + ResourcesPickerWindow.HeaderSpace)) / 16)));
                    this.SendSelection(this.selectedInstanceID);
                    this.Repaint();
                }
                else if (Event.current.keyCode == KeyCode.PageDown)
                {
                    this.selectedInstanceID = this.GetInstanceIDNeighbour(this.selectedInstanceID, Mathf.FloorToInt((this.position.height - (ResourcesPickerWindow.HeaderHeight + ResourcesPickerWindow.HeaderSpace)) / 16));
                    this.SendSelection(this.selectedInstanceID);
                    this.Repaint();
                }
                else if (Event.current.keyCode == KeyCode.Home)
                {
                    this.selectedInstanceID = 0;
                    this.SendSelection(this.selectedInstanceID);
                    this.Repaint();
                }
                else if (Event.current.keyCode == KeyCode.End)
                {
                    this.selectedInstanceID = this.GetInstanceIDFromIndex(this.GetCountResources() - 1, this.ids);
                    this.SendSelection(this.selectedInstanceID);
                    this.Repaint();
                }
                else if (Event.current.keyCode == KeyCode.Escape)
                {
                    this.SendSelection(this.initialInstanceID);
                }
                else if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter)
                {
                    this.SendSelection(this.selectedInstanceID);
                    this.Close();
                }
            }

            GUILayout.BeginHorizontal("ObjectPickerToolbar", GUILayoutOptionPool.Height(ResourcesPickerWindow.HeaderHeight));
            {
                EditorGUI.BeginChangeCheck();
                this.searchString = GUILayout.TextField(this.searchString, "SearchTextField");
                if (EditorGUI.EndChangeCheck() == true)
                {
                    this.RefreshFilter();
                }

                if (GUILayout.Button("", string.IsNullOrEmpty(this.searchString) ? "SearchCancelButtonEmpty" : "SearchCancelButton") == true)
                {
                    this.searchString       = string.Empty;
                    this.selectedInstanceID = 0;
                    GUI.FocusControl(null);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(-18F);
            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Toggle(this.currentTab == 0, "Assets", "ObjectPickerTab") == true)
                {
                    this.SetTab(0);
                }

                for (int i = 0; i < this.tabs.Count; i++)
                {
                    if (GUILayout.Toggle(this.currentTab == i + 1, this.tabs[i].name, "ObjectPickerTab") == true)
                    {
                        this.SetTab(i + 1);
                    }
                }

                GUILayout.FlexibleSpace();

                if (this.currentTab == 0)
                {
                    if (this.hierarchy.IsChannelBlocked(this.type.GetHashCode()) == true)
                    {
                        GUILayout.Label(GeneralStyles.StatusWheel, GUILayoutOptionPool.Width(20F));
                        this.Repaint();
                    }
                    else if (GUILayout.Button("Refresh", GUILayoutOptionPool.ExpandWidthFalse) == true)
                    {
                        this.hierarchy.LoadResources(this.type, true);
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(ResourcesPickerWindow.HeaderSpace);

            this.r.x      = 0F;
            this.r.y      = GUILayoutUtility.GetLastRect().yMax + ResourcesPickerWindow.HeaderSpace;
            this.r.width  = this.position.width;
            this.r.height = this.position.height - this.r.y;

            float bodyHeight = r.height;

            if (this.currentTab == 0)
            {
                this.resourcesCount  = this.GetCountResources() + 1;
                this.viewRect.height = this.resourcesCount * Constants.SingleLineHeight;

                this.scrollPosition = GUI.BeginScrollView(this.r, this.scrollPosition, this.viewRect);
                {
                    this.r.x      = 0F;
                    this.r.y      = 0F;
                    this.r.height = Constants.SingleLineHeight;

                    int i = 0;

                    foreach (string resource in this.ForResources(this.resources))
                    {
                        if (this.r.y + this.r.height <= this.scrollPosition.y)
                        {
                            this.r.y += this.r.height;
                            ++i;
                            continue;
                        }

                        int instanceID = this.GetInstanceIDFromIndex(i - 1, this.ids);

                        if (Event.current.type == EventType.Repaint && instanceID == this.selectedInstanceID)
                        {
                            EditorGUI.DrawRect(r, ResourcesPickerWindow.FocusBackgroundColor);
                        }
                        else if (Event.current.type == EventType.Repaint && instanceID == this.initialInstanceID)
                        {
                            EditorGUI.DrawRect(r, ResourcesPickerWindow.InitialBackgroundColor);
                        }

                        if (Event.current.type == EventType.MouseDown &&
                            this.r.Contains(Event.current.mousePosition) == true)
                        {
                            if (this.selectedInstanceID == instanceID)
                            {
                                this.Close();
                            }
                            else
                            {
                                this.selectedInstanceID = instanceID;
                                this.SendSelection(instanceID);
                            }

                            this.Repaint();

                            Event.current.Use();
                        }

                        GUI.Label(this.r, resource + " (#" + instanceID + ')');

                        this.r.y += this.r.height;
                        ++i;

                        if (this.r.y - this.scrollPosition.y > bodyHeight)
                        {
                            break;
                        }
                    }
                }
                GUI.EndScrollView();
            }
            else
            {
                this.tabs[this.currentTab - 1].OnGUI(this.r);
            }
        }
Esempio n. 10
0
        protected virtual void  OnGUI()
        {
            if (this.source == null || this.source.Initialized == false)
            {
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                if (this.source.backgroundColor.a > 0F)
                {
                    EditorGUI.DrawRect(new Rect(0F, 0F, this.position.width, this.position.height), this.source.backgroundColor);
                }
                else
                {
                    EditorGUI.DrawRect(new Rect(0F, 0F, this.position.width, this.position.height), NGHubWindow.DockBackgroundColor);
                }
            }

            if (this.overflowing == true)
            {
                Rect r = this.position;
                r.y     = 5F;
                r.x     = r.width - 20F;
                r.width = 20F;

                if (Event.current.type == EventType.MouseDown &&
                    Event.current.button == 0 &&
                    r.Contains(Event.current.mousePosition) == true)
                {
                    NGHubDropdownWindow[] windows = Resources.FindObjectsOfTypeAll <NGHubDropdownWindow>();

                    if (windows.Length > 0)
                    {
                        for (int i = 0; i < windows.Length; i++)
                        {
                            windows[i].Close();
                        }
                    }
                    else if (NGHubDropdownWindow.isDead == true)
                    {
                        NGHubDropdownWindow window = EditorWindow.CreateInstance <NGHubDropdownWindow>();

                        window.Init(this.source, this.hiddenI);

                        r.x  = this.position.x + this.position.width - 150F;
                        r.y += this.position.y - 5F;
                        window.ShowAsDropDown(r, new Vector2(150F, 4F + 24F * (this.source.components.Count - this.hiddenI)));
                    }
                }
            }

            EditorGUILayout.BeginHorizontal(GUILayoutOptionPool.Height(this.source.height));
            {
                this.source.HandleDrop();

                EventType catchedType = EventType.Used;

                if (Event.current.type == EventType.Repaint)
                {
                    this.overflowing = false;
                }

                for (int i = this.minI; i < this.source.components.Count; i++)
                {
                    // Catch event from the cropped component.
                    if (Event.current.type != EventType.Repaint &&
                        Event.current.type != EventType.Layout)
                    {
                        if (this.hiddenI == i)
                        {
                            // Simulate context click, because MouseUp is used, therefore ContextClick is not sent.
                            if (Event.current.type == EventType.MouseUp &&
                                Event.current.button == 1)
                            {
                                catchedType = EventType.ContextClick;
                            }
                            else
                            {
                                catchedType = Event.current.type;
                            }
                            Event.current.Use();
                        }
                    }

                    EditorGUILayout.BeginHorizontal();
                    {
                        this.source.components[i].OnGUI();
                    }
                    EditorGUILayout.EndHorizontal();

                    if (Event.current.type == EventType.Repaint)
                    {
                        Rect r = GUILayoutUtility.GetLastRect();

                        if (r.xMax >= this.position.width)
                        {
                            // Hide the miserable trick...
                            r.xMin -= 2F;
                            r.yMin -= 3F;
                            r.yMax += 2F;
                            r.xMax += 2F;
                            EditorGUI.DrawRect(r, NGHubWindow.DockBackgroundColor);
                            this.hiddenI     = i;
                            this.overflowing = true;
                            break;
                        }
                        else if (this.hiddenI == i)
                        {
                            --this.hiddenI;
                        }
                    }
                }

                if (Event.current.type == EventType.ContextClick ||
                    catchedType == EventType.ContextClick)
                {
                    this.source.OpenContextMenu();
                }
            }

            GUILayout.FlexibleSpace();

            if (this.overflowing == true)
            {
                Rect r = this.position;
                r.y     = 5F;
                r.x     = r.width - 20F;
                r.width = 20F;

                GUI.Button(r, "", "Dropdown");
            }

            EditorGUILayout.EndHorizontal();
        }
Esempio n. 11
0
        public override void    OnGUI()
        {
            if (this.unwrapLabel == null)
            {
                this.unwrapLabel          = new GUIStyle(GUI.skin.label);
                this.unwrapLabel.wordWrap = false;
                this.buttonLeft           = new GUIStyle("ButtonLeft");
                this.buttonRight          = new GUIStyle("ButtonRight");
                this.buttonMid            = new GUIStyle("ButtonMid");
            }

            for (int i = NGNavSelectionWindow.historic.Count - 1; i >= 0 && i >= NGNavSelectionWindow.historic.Count - this.maxElements; i--)
            {
                AssetsSelection selection = NGNavSelectionWindow.historic[i];
                Texture2D       image     = null;
                string          label     = string.Empty;

                if (selection.refs.Count > 0)
                {
                    if (selection.refs[0].@object == null)
                    {
                        if (selection.refs[0].hierarchy.Count > 0)
                        {
                            label = (string.IsNullOrEmpty(selection.refs[0].resolverAssemblyQualifiedName) == false ? "(R)" : "") + selection.refs[0].hierarchy[selection.refs[0].hierarchy.Count - 1];
                        }
                        else
                        {
                            label = "Unknown";
                        }
                    }
                    else
                    {
                        label = selection.refs[0][email protected];
                    }
                }

                if (selection.refs.Count > 1)
                {
                    label = "(" + selection.refs.Count + ") " + label;
                }

                image = Utility.GetIcon(selection.refs[0][email protected]());

                float    width = this.maxWidth;
                GUIStyle style;

                if (i == NGNavSelectionWindow.historic.Count - 1)
                {
                    style = this.buttonLeft;
                }
                else if (i == 0 || i == NGNavSelectionWindow.historic.Count - this.maxElements)
                {
                    style = this.buttonRight;
                }
                else
                {
                    style = this.buttonMid;
                }

                Rect r = GUILayoutUtility.GetRect(GUIContent.none, style, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(width));

                if (Event.current.type == EventType.MouseDrag &&
                    (this.dragOriginPosition - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance &&
                    i.Equals(DragAndDrop.GetGenericData(Utility.DragObjectDataName)) == true)
                {
                    DragAndDrop.StartDrag("Drag Object");
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.MouseDown &&
                         r.Contains(Event.current.mousePosition) == true)
                {
                    this.dragOriginPosition = Event.current.mousePosition;

                    if (Event.current.button == 0)
                    {
                        DragAndDrop.PrepareStartDrag();
                        DragAndDrop.objectReferences = new UnityEngine.Object[] { selection.refs[0].@object };
                        DragAndDrop.SetGenericData(Utility.DragObjectDataName, i);
                        DragAndDrop.SetGenericData(NGHubWindow.DragFromNGHub, true);
                    }
                }

                if (GUI.Button(r, string.Empty, style) == true)
                {
                    if (Event.current.button == 1 || this.lastClick + Constants.DoubleClickTime > EditorApplication.timeSinceStartup)
                    {
                        selection.Select();
                        NGNavSelectionWindow.lastFocusedHistoric = i;
                        Utility.RepaintEditorWindow(typeof(NGNavSelectionWindow));
                    }
                    else if (Event.current.button == 0)
                    {
                        EditorGUIUtility.PingObject(selection.refs[0].@object);
                    }

                    this.lastClick = EditorApplication.timeSinceStartup;
                }

                if (image != null)
                {
                    width = r.width;

                    r.xMax = r.xMin + 16F;
                    r.x   += 2F;
                    GUI.DrawTexture(r, image, ScaleMode.ScaleToFit);

                    r.xMin += r.width;
                    r.width = width - r.width - 20F;
                }

                r.y += 3F;
                Utility.content.text    = label;
                Utility.content.tooltip = label;
                GUI.Label(r, Utility.content, this.unwrapLabel);
            }

            Utility.content.tooltip = null;
        }
Esempio n. 12
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();
            }
        }
Esempio n. 13
0
        protected virtual void  OnGUI()
        {
            if (this.button == null)
            {
                this.button = new GUIStyle(GUI.skin.button);
                this.button.padding.left       = 16;
                this.scrollbar                 = new HorizontalScrollbar(0F, 18F, this.position.height);
                this.scrollbar.interceiptEvent = false;
            }

            float totalWidth = 0F;

            for (int i = 0; i < this.history.Count; i++)
            {
                totalWidth += GUI.skin.button.CalcSize(this.history[i].content).x + 20F + 4F;                 // Remove big texture width, because Button calculates using the whole height + Spacing
            }
            this.scrollbar.RealWidth = totalWidth;
            this.scrollbar.SetSize(this.position.width);
            this.scrollbar.OnGUI();

            EditorGUILayout.BeginHorizontal();
            {
                for (int i = 0; i < this.history.Count; i++)
                {
                    float w = GUI.skin.button.CalcSize(this.history[i].content).x + 20F;                       // Remove big texture width, because Button calculates using the whole height.
                    Rect  r = GUILayoutUtility.GetRect(0F, 0F, GUI.skin.button, GUILayoutOptionPool.Width(w), GUILayoutOptionPool.Height(Constants.SingleLineHeight));

                    r.x -= this.scrollbar.Offset;

                    if (GUI.Button(r, this.history[i].content, this.button) == true)
                    {
                        if (Event.current.button == 0)
                        {
                            this.master = i;
                        }
                        else
                        {
                            this.slave = i;
                        }
                    }

                    if (Event.current.type == EventType.Repaint)
                    {
                        r.x    += 5F;
                        r.width = r.height;
                        GUI.DrawTexture(r, this.history[i].icon);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(this.scrollbar.MaxHeight);

            Rect  r2   = GUILayoutUtility.GetLastRect();
            float half = this.position.width * .5F;

            EditorGUI.DrawRect(GUILayoutUtility.GetRect(this.position.width, 2F), Color.black);

            EditorGUILayout.BeginHorizontal();
            {
                this.scrollPositionMaster = GUILayout.BeginScrollView(this.scrollPositionMaster, GUILayoutOptionPool.Width(half));
                {
                    if (0 <= this.master && this.master < this.history.Count)
                    {
                        if (this.history[this.master].component == null)
                        {
                            this.history.RemoveAt(this.master);
                            this.master = -1;
                        }
                        else
                        {
                            this.DrawComponent(this.history[this.master]);
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Add a Component here from a Component's context menu or left click on the history above.", GeneralStyles.BigCenterText);
                    }
                }
                GUILayout.EndScrollView();

                EditorGUI.DrawRect(GUILayoutUtility.GetRect(1F, 1F, 0F, float.MaxValue), Color.black);

                this.scrollPositionSlave = EditorGUILayout.BeginScrollView(this.scrollPositionSlave, GUILayoutOptionPool.Width(half));
                {
                    if (0 <= this.slave && this.slave < this.history.Count)
                    {
                        if (this.history[this.slave].component == null)
                        {
                            this.history.RemoveAt(this.slave);
                            this.slave = -1;
                        }
                        else
                        {
                            this.DrawComponent(this.history[this.slave]);
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Add a Component here from a Component's context menu or right click on the history above.", GeneralStyles.BigCenterText);
                    }
                }
                EditorGUILayout.EndScrollView();

                r2.height = 48F;
                r2.width  = this.position.width;

                if (Event.current.type == EventType.DragUpdated &&
                    r2.Contains(Event.current.mousePosition) == true)
                {
                    if (typeof(Component).IsAssignableFrom(DragAndDrop.objectReferences[0].GetType()) == true)
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    }
                    else
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                    }
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.DragPerform &&
                         r2.Contains(Event.current.mousePosition) == true)
                {
                    DragAndDrop.AcceptDrag();

                    ComponentContainer container = new ComponentContainer(DragAndDrop.objectReferences[0] as Component);

                    this.history.Add(container);

                    if (Event.current.mousePosition.x < half)
                    {
                        this.master = this.history.Count - 1;
                    }
                    else
                    {
                        this.slave = this.history.Count - 1;
                    }

                    DragAndDrop.PrepareStartDrag();
                    Event.current.Use();
                }

                if (Event.current.type == EventType.Repaint &&
                    DragAndDrop.objectReferences.Length > 0)
                {
                    r2.width = half;
                    Utility.DropZone(r2, "Drop here");

                    r2.x = r2.width;
                    Utility.DropZone(r2, "Drop here");
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        public override void    OnEditionGUI()
        {
            using (LabelWidthRestorer.Get(100F))
            {
                if (this.methodInfo != null)
                {
                    EditorGUILayout.LabelField("Static Method", this.methodInfo.DeclaringType.Name + ":" + this.methodInfo.Name + "()");
                    this.alias = EditorGUILayout.TextField("Alias", this.alias);


                    Rect r2 = GUILayoutUtility.GetLastRect();
                    r2.y     += r2.height + 3F;
                    r2.height = 1F;
                    EditorGUI.DrawRect(r2, Color.gray);

                    GUILayout.Space(5F);
                }

                Rect  r     = GUILayoutUtility.GetRect(0F, Constants.SingleLineHeight, GUI.skin.textField);
                float width = r.width;

                EditorGUI.BeginChangeCheck();
                this.type = EditorGUI.TextField(r, "Search Type", this.type);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    this.RefreshTypes();
                    return;
                }

                this.filterTypesScrollPosition = EditorGUILayout.BeginScrollView(this.filterTypesScrollPosition, GUILayoutOptionPool.Height(Mathf.Min(this.matchingTypes.Count * 18F + 10F, 160F)), GUILayoutOptionPool.ExpandHeightFalse);
                {
                    for (int i = 0; i < this.matchingTypes.Count; i++)
                    {
                        if (GUILayout.Button(this.matchingTypes[i].Name) == true)
                        {
                            this.selectedType           = this.matchingTypes[i];
                            this.availableStaticMethods = this.selectedType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                            return;
                        }
                    }
                }
                EditorGUILayout.EndScrollView();

                if (this.availableStaticMethods != null)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Selected Type", this.selectedType.FullName);

                    if (this.availableStaticMethods.Length == 0)
                    {
                        GUILayout.Label("No static method found.");
                    }
                    else
                    {
                        this.methodsScrollPosition = EditorGUILayout.BeginScrollView(this.methodsScrollPosition, GUILayoutOptionPool.Height(Mathf.Min(this.availableStaticMethods.Length * 18F + 10F, 160F)), GUILayoutOptionPool.ExpandHeightFalse);
                        {
                            for (int i = 0; i < this.availableStaticMethods.Length; i++)
                            {
                                if (GUILayout.Button(this.availableStaticMethods[i].Name) == true)
                                {
                                    this.methodInfo = this.availableStaticMethods[i];
                                    this.typeString = this.selectedType.AssemblyQualifiedName;
                                    this.methodName = this.methodInfo.Name;
                                    return;
                                }
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                }
            }
        }
Esempio n. 15
0
        protected virtual void  OnGUI()
        {
            if (this.initialized == false)
            {
                // Prevent initialization message after entering play mode.
                if (Time.frameCount <= 2)
                {
                    return;
                }

                GUILayout.Label(string.Format(LC.G("RequiringConfigurationFile"), NGHubWindow.Title), GeneralStyles.CenterText, GUILayoutOptionPool.Height(this.height));

                if (this.dockedAsMenu == false)
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (GUILayout.Button(LC.G("ShoWPreferencesWindow")) == true)
                        {
                            Utility.ShowPreferencesWindowAt(Constants.PreferenceTitle);
                        }

                        // Especially for NG Hub, we need to add a way to manually close the window when the dock mode is failing.
                        if (GUILayout.Button("X", GUILayoutOptionPool.Width(16F)) == true)
                        {
                            this.Close();
                        }
                    }
                    GUILayout.EndHorizontal();
                }

                return;
            }

            FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGHubWindow.FreeAdContent);

            if (Event.current.type == EventType.Repaint)
            {
                if (this.backgroundColor.a > 0F)
                {
                    EditorGUI.DrawRect(new Rect(0F, 0F, this.position.width, this.position.height), this.backgroundColor);
                }
                else
                {
                    EditorGUI.DrawRect(new Rect(0F, 0F, this.position.width, this.position.height), NGHubWindow.DockBackgroundColor);
                }
            }

            EditorGUILayout.BeginHorizontal(GUILayoutOptionPool.Height(this.height));
            {
                if (this.errorPopup.exception != null)
                {
                    if (this.dockedAsMenu == true)
                    {
                        Rect r = GUILayoutUtility.GetRect(0F, 0F, GUILayoutOptionPool.Width(115F), GUILayoutOptionPool.Height(this.height + 3F));
                        r.x += 1F;
                        r.y += 1F;
                        this.errorPopup.OnGUIRect(r);
                    }
                    else
                    {
                        this.errorPopup.OnGUILayout();
                    }
                }

                bool      isDragging  = this.HandleDrop();
                bool      overflow    = false;
                EventType catchedType = EventType.Used;

                if (this.components.Count == 0)
                {
                    if (isDragging == false)
                    {
                        Rect r = this.position;
                        r.x       = 1F;
                        r.y       = 1F;
                        r.width  -= 1F;
                        r.height -= 1F;

                        if (this.dockedAsMenu == true && Event.current.type == EventType.Repaint)
                        {
                            Utility.DrawRectDotted(r, this.position, Color.grey, .02F, 0F);
                        }

                        GUI.Label(r, "Right-click to add Component" + (this.dockedAsMenu == true && Application.platform == RuntimePlatform.OSXEditor? " (Dock mode is buggy under OSX)" : ""), GeneralStyles.CenterText);
                    }
                }
                else
                {
                    Rect miseryRect = default(Rect);
                    int  lastMinI   = this.extensionWindow != null ? this.extensionWindow.minI : 0;

                    if (this.dockedAsMenu == true &&
                        this.extensionWindow != null &&
                        this.maxWidth > 0F)
                    {
                        miseryRect = new Rect(this.maxWidth, 0F, this.position.width - this.maxWidth, this.height + 4F);
                        GUI.Label(miseryRect, GUIContent.none);

                        if (miseryRect.Contains(Event.current.mousePosition) == true)
                        {
                            GUIUtility.hotControl = 0;
                        }
                    }

                    for (int i = 0; i < this.components.Count; i++)
                    {
                        // Catch event from the cropped component.
                        if (this.dockedAsMenu == true &&
                            Event.current.type != EventType.Repaint &&
                            Event.current.type != EventType.Layout &&
                            this.extensionWindow != null)
                        {
                            if (this.extensionWindow.minI == i)
                            {
                                // Simulate context click, because MouseUp is used, therefore ContextClick is not sent.
                                if (Event.current.type == EventType.MouseUp &&
                                    Event.current.button == 1)
                                {
                                    catchedType = EventType.ContextClick;
                                }
                                else
                                {
                                    catchedType = Event.current.type;
                                }
                                Event.current.Use();
                            }
                        }

                        EditorGUILayout.BeginHorizontal();
                        {
                            try
                            {
                                this.components[i].OnGUI();
                            }
                            catch (Exception ex)
                            {
                                this.errorPopup.exception = ex;
                            }
                        }
                        EditorGUILayout.EndHorizontal();

                        if (this.dockedAsMenu == true && Event.current.type == EventType.Repaint)
                        {
                            Rect r = GUILayoutUtility.GetLastRect();

                            if (r.xMax >= this.position.width)
                            {
                                if (this.extensionWindow == null)
                                {
                                    this.extensionWindow = ScriptableObject.CreateInstance <NGHubExtensionWindow>();
                                    this.extensionWindow.Init(this);
                                    this.extensionWindow.ShowPopup();
                                    this.Repaint();
                                }

                                this.maxWidth             = r.xMin;
                                this.extensionWindow.minI = i;
                                overflow = true;
                                break;
                            }
                            else if (this.position.width - r.xMax <= 16F && i + 1 < this.components.Count)                             // Prevent drawing next component if the space is obviously too small.
                            {
                                if (this.extensionWindow == null)
                                {
                                    this.extensionWindow = ScriptableObject.CreateInstance <NGHubExtensionWindow>();
                                    this.extensionWindow.Init(this);
                                    this.extensionWindow.ShowPopup();
                                    this.Repaint();
                                }

                                this.maxWidth             = r.xMax;
                                this.extensionWindow.minI = i + 1;
                                overflow = true;
                                break;
                            }
                            else
                            {
                                this.maxWidth = 0F;
                            }
                        }
                    }

                    if (this.dockedAsMenu == true)
                    {
                        if (this.extensionWindow != null &&
                            this.maxWidth > 0F)
                        {
                            if (lastMinI != this.extensionWindow.minI)
                            {
                                this.Repaint();
                            }

                            // Hide the miserable trick...
                            if (Event.current.type == EventType.Repaint)
                            {
                                if (this.backgroundColor.a > 0F)
                                {
                                    EditorGUI.DrawRect(miseryRect, this.backgroundColor);
                                }
                                else
                                {
                                    EditorGUI.DrawRect(miseryRect, NGHubWindow.DockBackgroundColor);
                                }
                            }
                        }
                        else
                        {
                            Rect r = GUILayoutUtility.GetLastRect();

                            r.xMin  = r.xMax + 1F;
                            r.width = this.position.width - r.x;
                            r.yMin -= 3F;
                            r.yMax += 3F;

                            if (Event.current.type == EventType.Repaint)
                            {
                                if (this.backgroundColor.a > 0F)
                                {
                                    EditorGUI.DrawRect(r, this.backgroundColor);
                                }
                                else
                                {
                                    EditorGUI.DrawRect(r, NGHubWindow.DockBackgroundColor);
                                }
                            }
                        }
                    }
                }

                if (this.dockedAsMenu == true &&
                    Event.current.type == EventType.Repaint &&
                    overflow == false &&
                    this.extensionWindow != null)
                {
                    this.extensionWindow.Close();
                    this.extensionWindow = null;
                    base.Repaint();
                }

                if (Event.current.type == EventType.ContextClick ||
                    catchedType == EventType.ContextClick)
                {
                    this.OpenContextMenu();
                }
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro");
        }
Esempio n. 16
0
        public void     Draw(NGMissingScriptRecoveryWindow window, bool force = false)
        {
            if (this.cachedFields == null)
            {
                StringBuilder buffer = Utility.GetBuffer();

                for (int i = 0; i < this.fields.Count; i++)
                {
                    buffer.AppendLine(this.fields[i]);
                }

                if (buffer.Length > 0)
                {
                    buffer.Length -= Environment.NewLine.Length;
                }

                this.cachedFields = Utility.ReturnBuffer(buffer);
            }

            EditorGUI.BeginDisabledGroup(this.fields.Count <= 0);
            {
                Utility.content.text  = this.name;
                Utility.content.image = Utility.GetIcon(this.asset ? this.asset.GetInstanceID() : 0);
                this.open             = EditorGUILayout.Foldout(this.open, Utility.content) && this.fields.Count > 0 || force;
                Utility.content.image = null;
            }
            EditorGUI.EndDisabledGroup();

            if (this.fields.Count == 0 && this.asset == null)
            {
                EditorGUILayout.HelpBox("Component seems to have absolutely no fields. Recovery can not proceed.", MessageType.Warning);
            }

            if (this.open == false)
            {
                return;
            }

            ++EditorGUI.indentLevel;
            this.fieldsOpen = EditorGUILayout.Foldout(this.fieldsOpen, "Fields found (" + this.fields.Count + ")");
            if (this.fieldsOpen == true)
            {
                ++EditorGUI.indentLevel;
                Utility.content.text = this.cachedFields;
                float h = EditorStyles.label.CalcHeight(Utility.content, window.position.width - 60F);
                //float h = this.fields.Count * 15F;
                float totalH = h;

                if (h >= NGMissingScriptRecoveryWindow.MaxFieldsHeight)
                {
                    h = NGMissingScriptRecoveryWindow.MaxFieldsHeight;
                }

                //Utility.content.text = this.cachedFields;
                //Rect	viewRect = new Rect();
                //Rect	body = new Rect(4F, GUILayoutUtility.GetLastRect().yMax, window.position.width, 0F);
                //Rect	r2 = GUILayoutUtility.GetRect(0F, h);
                //body.height = r2.height;
                //viewRect.height = EditorStyles.label.CalcSize(Utility.content).y;

                //EditorGUI.DrawRect(body, Color.blue);
                //this.scrollPositionFields = GUI.BeginScrollView(body, this.scrollPositionFields, viewRect);
                //{
                //	Rect	selectableRect = body;
                //	selectableRect.x = 0F;
                //	selectableRect.y = 0F;
                //	selectableRect.width = body.width - (viewRect.height > body.height ? 16F : 0F);
                //	selectableRect.height = viewRect.height > body.height ? EditorStyles.label.CalcHeight(Utility.content, selectableRect.width) : viewRect.height;
                //	EditorGUI.SelectableLabel(selectableRect, this.cachedFields, EditorStyles.label);
                //}
                //GUI.EndScrollView();

                // TODO Fix bottom margin/padding?
                EditorGUI.HelpBox(new Rect(30F, GUILayoutUtility.GetLastRect().yMax, window.position.width - 60F, h + 10F), string.Empty, MessageType.None);
                //if (useScrollbar == true)
                this.scrollPositionFields = EditorGUILayout.BeginScrollView(this.scrollPositionFields, GUILayoutOptionPool.Height(h + 5F), GUILayoutOptionPool.Width(window.position.width - 30F));
                //else
                //EditorGUI.HelpBox(new Rect(4F, GUILayoutUtility.GetLastRect().yMax, window.position.width, h), string.Empty, MessageType.None);
                {
                    EditorGUILayout.SelectableLabel(this.cachedFields, EditorStyles.label, GUILayoutOptionPool.Height(totalH));
                    //for (int j = 0; j < this.fields.Count; j++)
                    //	EditorGUILayout.LabelField(this.fields[j]);
                }
                //if (useScrollbar == true)
                EditorGUILayout.EndScrollView();
                --EditorGUI.indentLevel;
            }

            CachedLineFix lineFix = window.FindCachedComponentFixes(this.line);

            if (lineFix != null)
            {
                if (GUILayout.Button("Recover From Cache (" + lineFix.type + ")") == true)
                {
                    this.FixLine(window, this.componentID, lineFix.type);
                    window.Diagnose(window.Target);
                }
            }

            EditorGUILayout.LabelField("Potential types:");
            ++EditorGUI.indentLevel;
            if (this.potentialTypes.Count == 0)
            {
                EditorGUILayout.LabelField("No type available.");
            }
            else
            {
                for (int l = 0; l < this.potentialTypes.Count; l++)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(30F);

                        if (GUILayout.Button(this.potentialTypes[l].type.FullName, GUILayoutOptionPool.ExpandWidthFalse) == true)
                        {
                            this.FixMissingComponent(window, this.componentID, this.potentialTypes[l].type);
                            window.Diagnose(window.Target);
                            return;
                        }

                        if (this.potentialTypes[l].matchingFields == this.fields.Count &&
                            this.potentialTypes[l].fields.Length == this.fields.Count)
                        {
                            GUILayout.Label("(Perfect match)", GUILayoutOptionPool.ExpandWidthFalse);
                        }
                        else
                        {
                            int extraFields = this.potentialTypes[l].fields.Length == this.potentialTypes[l].matchingFields ? this.potentialTypes[l].matchingFields - this.fields.Count : this.potentialTypes[l].fields.Length - this.potentialTypes[l].matchingFields;
                            GUILayout.Label("(Fields: " + this.potentialTypes[l].matchingFields + " matching" + (extraFields > 0 ? ", +" + extraFields + " extra" : (extraFields < 0 ? ", " + extraFields + " missing" : string.Empty)) + ")", GUILayoutOptionPool.ExpandWidthFalse);
                        }

                        if (Event.current.type == EventType.MouseMove)
                        {
                            Rect r = GUILayoutUtility.GetLastRect();

                            r.xMin = 0F;
                            if (r.Contains(Event.current.mousePosition) == true)
                            {
                                if (this.hoverPopup != null)
                                {
                                    if (this.hoverPopup.potentialType.type != this.potentialTypes[l].type)
                                    {
                                        if (this.hoverPopup.editorWindow != null)
                                        {
                                            this.hoverPopup.editorWindow.Close();
                                        }
                                        this.hoverPopup = new HighlightMatchesPopup(this, this.potentialTypes[l]);
                                        r.x             = 30F;
                                        r.y            += 5F;
                                        PopupWindow.Show(r, this.hoverPopup);
                                    }
                                }
                                else
                                {
                                    this.hoverPopup = new HighlightMatchesPopup(this, this.potentialTypes[l]);
                                    r.x             = 30F;
                                    r.y            += 5F;
                                    PopupWindow.Show(r, this.hoverPopup);
                                }
                            }
                            else
                            {
                                if (this.hoverPopup != null && this.hoverPopup.potentialType.type == this.potentialTypes[l].type)
                                {
                                    if (this.hoverPopup.editorWindow != null)
                                    {
                                        this.hoverPopup.editorWindow.Close();
                                    }
                                    this.hoverPopup = null;
                                }
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            --EditorGUI.indentLevel;
            --EditorGUI.indentLevel;
        }
Esempio n. 17
0
        public override void    OnGUI()
        {
            if (this.buttonLeft == null)
            {
                this.buttonLeft  = "ButtonLeft";
                this.buttonMid   = "ButtonMid";
                this.buttonRight = "ButtonRight";
            }

            Utility.content.text    = "R";
            Utility.content.tooltip = "Reset time to 1";
            if (GUILayout.Button(Utility.content, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height)) == true)
            {
                Time.timeScale = 1F;
                GUI.FocusControl(null);
            }
            Utility.content.tooltip = string.Empty;

            int last = 0;

            if (this.presets1 >= TimeScaleComponent.MinTime)
            {
                ++last;
            }
            if (this.presets2 >= TimeScaleComponent.MinTime)
            {
                ++last;
            }
            if (this.presets3 >= TimeScaleComponent.MinTime)
            {
                ++last;
            }

            if (this.presets1 >= TimeScaleComponent.MinTime && GUILayout.Button(this.presetContent1, (--last != 0) ? this.buttonMid : this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true)
            {
                Time.timeScale = this.presets1;
                GUI.FocusControl(null);
            }

            if (this.presets2 >= TimeScaleComponent.MinTime && GUILayout.Button(this.presetContent2, (--last != 0) ? this.buttonMid : this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true)
            {
                Time.timeScale = this.presets2;
                GUI.FocusControl(null);
            }

            if (this.presets3 >= TimeScaleComponent.MinTime && GUILayout.Button(this.presetContent3, (--last != 0) ? this.buttonMid : this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true)
            {
                Time.timeScale = this.presets3;
                GUI.FocusControl(null);
            }

            using (LabelWidthRestorer.Get(15F))
            {
                EditorGUI.BeginChangeCheck();
                Utility.content.text = Time.timeScale.ToString();
                float v = EditorGUILayout.FloatField(" ", Time.timeScale, GeneralStyles.VerticalCenterTextField, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(20F + GUI.skin.label.CalcSize(Utility.content).x));
                if (EditorGUI.EndChangeCheck() == true)
                {
                    Time.timeScale = Mathf.Clamp(v, TimeScaleComponent.MinTime, TimeScaleComponent.MaxTime);
                }

                Rect r = GUILayoutUtility.GetLastRect();
                r.width = 15F;
                GUI.Label(r, "T", GeneralStyles.CenterText);
            }
        }