From dc2759c5992899560ff17ae5ffe3d52583f6435d Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Mon, 14 Sep 2020 01:42:29 +1000 Subject: [PATCH] 1.7.2 unstrip fixes --- src/CachedObjects/CacheObjectBase.cs | 22 ++--- src/CachedObjects/Object/CacheDictionary.cs | 20 ++--- src/CachedObjects/Object/CacheList.cs | 16 ++-- src/CachedObjects/Other/CacheMethod.cs | 4 +- src/CachedObjects/Other/CacheOther.cs | 2 +- src/CachedObjects/Struct/CacheColor.cs | 24 ++--- src/CachedObjects/Struct/CacheEnum.cs | 6 +- src/CachedObjects/Struct/CachePrimitive.cs | 12 +-- src/CachedObjects/Struct/CacheQuaternion.cs | 21 ++--- src/CachedObjects/Struct/CacheRect.cs | 24 ++--- src/CachedObjects/Struct/CacheVector.cs | 24 ++--- src/CppExplorer.cs | 2 +- src/CppExplorer.csproj | 2 +- src/Helpers/PageHelper.cs | 6 +- src/Menu/MainMenu/MainMenu.cs | 8 +- src/Menu/MainMenu/Pages/ConsolePage.cs | 20 ++--- src/Menu/MainMenu/Pages/ScenePage.cs | 36 ++++---- src/Menu/MainMenu/Pages/SearchPage.cs | 32 +++---- src/{Helpers => Menu}/UIHelpers.cs | 10 +-- src/Menu/UIStyles.cs | 2 +- src/Menu/Windows/GameObjectWindow.cs | 99 +++++++++++---------- src/Menu/Windows/ReflectionWindow.cs | 30 +++---- src/Menu/Windows/ResizeDrag.cs | 18 ++-- src/Menu/Windows/TabViewWindow.cs | 4 +- src/UnstripFixes/GUIUnstrip.cs | 85 +++++++++++++++++- 25 files changed, 305 insertions(+), 224 deletions(-) rename src/{Helpers => Menu}/UIHelpers.cs (87%) diff --git a/src/CachedObjects/CacheObjectBase.cs b/src/CachedObjects/CacheObjectBase.cs index f47ef83..d5b48a6 100644 --- a/src/CachedObjects/CacheObjectBase.cs +++ b/src/CachedObjects/CacheObjectBase.cs @@ -379,7 +379,7 @@ namespace Explorer if (MemInfo != null) { - GUILayout.Label(RichTextName, new GUILayoutOption[] { GUILayout.Width(labelWidth) }); + GUIUnstrip.Label(RichTextName, new GUILayoutOption[] { GUILayout.Width(labelWidth) }); } else { @@ -408,15 +408,15 @@ namespace Explorer GUIUnstrip.BeginHorizontal(); - GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(20) }); - m_argumentInput[i] = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) }); - GUILayout.Label(label, null); + GUIUnstrip.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(20) }); + m_argumentInput[i] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) }); + GUIUnstrip.Label(label); GUIUnstrip.EndHorizontal(); } GUIUnstrip.BeginHorizontal(); - if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) })) + if (GUIUnstrip.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) })) { if (cm != null) { @@ -427,7 +427,7 @@ namespace Explorer UpdateValue(); } } - if (GUILayout.Button("Cancel", new GUILayoutOption[] { GUILayout.Width(70) })) + if (GUIUnstrip.Button("Cancel", new GUILayoutOption[] { GUILayout.Width(70) })) { m_isEvaluating = false; } @@ -435,7 +435,7 @@ namespace Explorer } else { - if (GUILayout.Button($"Evaluate ({m_arguments.Length} params)", new GUILayoutOption[] { GUILayout.Width(150) })) + if (GUIUnstrip.Button($"Evaluate ({m_arguments.Length} params)", new GUILayoutOption[] { GUILayout.Width(150) })) { m_isEvaluating = true; } @@ -452,7 +452,7 @@ namespace Explorer { //GUIUnstrip.BeginHorizontal(); - if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) })) + if (GUIUnstrip.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) })) { cm.Evaluate(); } @@ -465,15 +465,15 @@ namespace Explorer if (!string.IsNullOrEmpty(ReflectionException)) { - GUILayout.Label("Reflection failed! (" + ReflectionException + ")", null); + GUIUnstrip.Label("Reflection failed! (" + ReflectionException + ")"); } else if ((HasParameters || this is CacheMethod) && !m_evaluated) { - GUILayout.Label($"Not yet evaluated ({ValueTypeName})", null); + GUIUnstrip.Label($"Not yet evaluated ({ValueTypeName})"); } else if (Value == null && !(this is CacheMethod)) { - GUILayout.Label("null (" + ValueTypeName + ")", null); + GUIUnstrip.Label("null (" + ValueTypeName + ")"); } else { diff --git a/src/CachedObjects/Object/CacheDictionary.cs b/src/CachedObjects/Object/CacheDictionary.cs index 7c6e0ec..780ac7a 100644 --- a/src/CachedObjects/Object/CacheDictionary.cs +++ b/src/CachedObjects/Object/CacheDictionary.cs @@ -202,7 +202,7 @@ namespace Explorer { if (m_cachedKeys == null || m_cachedValues == null) { - GUILayout.Label("Cached keys or values is null!", null); + GUIUnstrip.Label("Cached keys or values is null!"); return; } @@ -212,14 +212,14 @@ namespace Explorer if (!IsExpanded) { - if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = true; } } else { - if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = false; } @@ -229,7 +229,7 @@ namespace Explorer GUI.skin.button.alignment = TextAnchor.MiddleLeft; string btnLabel = $"[{count}] Dictionary<{TypeOfKeys.FullName}, {TypeOfValues.FullName}>"; - if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) })) + if (GUIUnstrip.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) })) { WindowManager.InspectObject(Value, out bool _); } @@ -251,11 +251,11 @@ namespace Explorer Pages.CurrentPageLabel(); // prev/next page buttons - if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(60) })) + if (GUIUnstrip.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(60) })) { Pages.TurnPage(Turn.Left); } - if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(60) })) + if (GUIUnstrip.Button("Next >", new GUILayoutOption[] { GUILayout.Width(60) })) { Pages.TurnPage(Turn.Right); } @@ -280,17 +280,17 @@ namespace Explorer if (key == null || val == null) { - GUILayout.Label($"[{i}] (null)", null); + GUIUnstrip.Label($"[{i}] (null)"); } else { GUI.skin.label.alignment = TextAnchor.MiddleCenter; - GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) }); + GUIUnstrip.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) }); - GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) }); + GUIUnstrip.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) }); key.DrawValue(window, (window.width / 2) - 30f); - GUILayout.Label("Value:", new GUILayoutOption[] { GUILayout.Width(40) }); + GUIUnstrip.Label("Value:", new GUILayoutOption[] { GUILayout.Width(40) }); val.DrawValue(window, (window.width / 2) - 30f); } diff --git a/src/CachedObjects/Object/CacheList.cs b/src/CachedObjects/Object/CacheList.cs index 2f815dd..722ad75 100644 --- a/src/CachedObjects/Object/CacheList.cs +++ b/src/CachedObjects/Object/CacheList.cs @@ -264,7 +264,7 @@ namespace Explorer { if (m_cachedEntries == null) { - GUILayout.Label("m_cachedEntries is null!", null); + GUIUnstrip.Label("m_cachedEntries is null!"); return; } @@ -274,14 +274,14 @@ namespace Explorer if (!IsExpanded) { - if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = true; } } else { - if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = false; } @@ -291,7 +291,7 @@ namespace Explorer GUI.skin.button.alignment = TextAnchor.MiddleLeft; string btnLabel = $"[{count}] {EntryType.FullName}"; - if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.MaxWidth(negativeWhitespace) })) + if (GUIUnstrip.Button(btnLabel, new GUILayoutOption[] { GUILayout.MaxWidth(negativeWhitespace) })) { WindowManager.InspectObject(Value, out bool _); } @@ -313,11 +313,11 @@ namespace Explorer Pages.CurrentPageLabel(); // prev/next page buttons - if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(60) })) + if (GUIUnstrip.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(60) })) { Pages.TurnPage(Turn.Left); } - if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(60) })) + if (GUIUnstrip.Button("Next >", new GUILayoutOption[] { GUILayout.Width(60) })) { Pages.TurnPage(Turn.Right); } @@ -341,12 +341,12 @@ namespace Explorer if (entry == null || entry.Value == null) { - GUILayout.Label($"[{i}] (null)", null); + GUIUnstrip.Label($"[{i}] (null)"); } else { GUI.skin.label.alignment = TextAnchor.MiddleCenter; - GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) }); + GUIUnstrip.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) }); entry.DrawValue(window, window.width - (whitespace + 85)); } diff --git a/src/CachedObjects/Other/CacheMethod.cs b/src/CachedObjects/Other/CacheMethod.cs index 6ce890e..b7f1ced 100644 --- a/src/CachedObjects/Other/CacheMethod.cs +++ b/src/CachedObjects/Other/CacheMethod.cs @@ -78,12 +78,12 @@ namespace Explorer } else { - GUILayout.Label($"null ({ValueTypeName})", null); + GUIUnstrip.Label($"null ({ValueTypeName})"); } } else { - GUILayout.Label($"Not yet evaluated ({ValueTypeName})", null); + GUIUnstrip.Label($"Not yet evaluated ({ValueTypeName})"); } } } diff --git a/src/CachedObjects/Other/CacheOther.cs b/src/CachedObjects/Other/CacheOther.cs index 97ce07b..857c5b7 100644 --- a/src/CachedObjects/Other/CacheOther.cs +++ b/src/CachedObjects/Other/CacheOther.cs @@ -55,7 +55,7 @@ namespace Explorer } GUI.skin.button.alignment = TextAnchor.MiddleLeft; - if (GUILayout.Button(label, new GUILayoutOption[] { GUILayout.Width(width - 15) })) + if (GUIUnstrip.Button(label, new GUILayoutOption[] { GUILayout.Width(width - 15) })) { WindowManager.InspectObject(Value, out bool _); } diff --git a/src/CachedObjects/Struct/CacheColor.cs b/src/CachedObjects/Struct/CacheColor.cs index 0301965..f05fd1f 100644 --- a/src/CachedObjects/Struct/CacheColor.cs +++ b/src/CachedObjects/Struct/CacheColor.cs @@ -35,14 +35,14 @@ namespace Explorer { if (!IsExpanded) { - if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = true; } } else { - if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = false; } @@ -51,7 +51,7 @@ namespace Explorer //var c = (Color)Value; //GUI.color = c; - GUILayout.Label($"Color: {((Color)Value).ToString()}", null); + GUIUnstrip.Label($"Color: {((Color)Value).ToString()}"); //GUI.color = Color.white; if (CanWrite && IsExpanded) @@ -62,32 +62,32 @@ namespace Explorer GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) }); - r = GUILayout.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) }); + r = GUIUnstrip.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) }); - g = GUILayout.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) }); + g = GUIUnstrip.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) }); - b = GUILayout.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) }); + b = GUIUnstrip.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) }); - a = GUILayout.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) }); + a = GUIUnstrip.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); // draw set value button GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) + if (GUIUnstrip.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } diff --git a/src/CachedObjects/Struct/CacheEnum.cs b/src/CachedObjects/Struct/CacheEnum.cs index f90d8f7..b7625d8 100644 --- a/src/CachedObjects/Struct/CacheEnum.cs +++ b/src/CachedObjects/Struct/CacheEnum.cs @@ -39,19 +39,19 @@ namespace Explorer { if (CanWrite) { - if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("<", new GUILayoutOption[] { GUILayout.Width(25) })) { SetEnum(ref Value, -1); SetValue(); } - if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button(">", new GUILayoutOption[] { GUILayout.Width(25) })) { SetEnum(ref Value, 1); SetValue(); } } - GUILayout.Label(Value.ToString() + " (" + ValueType + ")", null); + GUIUnstrip.Label(Value.ToString() + " (" + ValueType + ")"); } public void SetEnum(ref object value, int change) diff --git a/src/CachedObjects/Struct/CachePrimitive.cs b/src/CachedObjects/Struct/CachePrimitive.cs index 6c55a19..c1ab48c 100644 --- a/src/CachedObjects/Struct/CachePrimitive.cs +++ b/src/CachedObjects/Struct/CachePrimitive.cs @@ -55,7 +55,7 @@ namespace Explorer if (CanWrite) { - b = GUILayout.Toggle(b, label, null); + b = GUIUnstrip.Toggle(b, label); if (b != (bool)Value) { SetValueFromInput(b.ToString()); @@ -63,13 +63,13 @@ namespace Explorer } else { - GUILayout.Label(label, null); + GUIUnstrip.Label(label); } } else { // using ValueType.Name instead of ValueTypeName, because we only want the short name. - GUILayout.Label("" + ValueType.Name + "", new GUILayoutOption[] { GUILayout.Width(50) }); + GUIUnstrip.Label("" + ValueType.Name + "", new GUILayoutOption[] { GUILayout.Width(50) }); int dynSize = 25 + (m_valueToString.Length * 15); var maxwidth = window.width - 310f; @@ -77,16 +77,16 @@ namespace Explorer if (dynSize > maxwidth) { - m_valueToString = GUILayout.TextArea(m_valueToString, new GUILayoutOption[] { GUILayout.MaxWidth(maxwidth) }); + m_valueToString = GUIUnstrip.TextArea(m_valueToString, new GUILayoutOption[] { GUILayout.MaxWidth(maxwidth) }); } else { - m_valueToString = GUILayout.TextField(m_valueToString, new GUILayoutOption[] { GUILayout.MaxWidth(dynSize) }); + m_valueToString = GUIUnstrip.TextField(m_valueToString, new GUILayoutOption[] { GUILayout.MaxWidth(dynSize) }); } if (CanWrite) { - if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(60) })) + if (GUIUnstrip.Button("Apply", new GUILayoutOption[] { GUILayout.Width(60) })) { SetValueFromInput(m_valueToString); } diff --git a/src/CachedObjects/Struct/CacheQuaternion.cs b/src/CachedObjects/Struct/CacheQuaternion.cs index 19b12b8..63f8f08 100644 --- a/src/CachedObjects/Struct/CacheQuaternion.cs +++ b/src/CachedObjects/Struct/CacheQuaternion.cs @@ -33,21 +33,22 @@ namespace Explorer { if (!IsExpanded) { - if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = true; } } else { - if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = false; } } } - GUILayout.Label($"Quaternion: {((Quaternion)Value).eulerAngles.ToString()}", null); + string lbl = $"Quaternion: {((Quaternion)Value).eulerAngles.ToString()}"; + GUIUnstrip.Label(lbl); if (CanWrite && IsExpanded) { @@ -57,26 +58,26 @@ namespace Explorer GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); - x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); + x = GUIUnstrip.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); - y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); + y = GUIUnstrip.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); - z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); + z = GUIUnstrip.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); // draw set value button GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) + if (GUIUnstrip.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } diff --git a/src/CachedObjects/Struct/CacheRect.cs b/src/CachedObjects/Struct/CacheRect.cs index fb81641..1e11777 100644 --- a/src/CachedObjects/Struct/CacheRect.cs +++ b/src/CachedObjects/Struct/CacheRect.cs @@ -35,21 +35,21 @@ namespace Explorer { if (!IsExpanded) { - if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = true; } } else { - if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = false; } } } - GUILayout.Label($"Rect: {((Rect)Value).ToString()}", null); + GUIUnstrip.Label($"Rect: {((Rect)Value).ToString()}"); if (CanWrite && IsExpanded) { @@ -59,32 +59,32 @@ namespace Explorer GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); - x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); + x = GUIUnstrip.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); - y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); + y = GUIUnstrip.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); - w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); + w = GUIUnstrip.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("H:", new GUILayoutOption[] { GUILayout.Width(30) }); - h = GUILayout.TextField(h, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("H:", new GUILayoutOption[] { GUILayout.Width(30) }); + h = GUIUnstrip.TextField(h, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); // draw set value button GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) + if (GUIUnstrip.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } diff --git a/src/CachedObjects/Struct/CacheVector.cs b/src/CachedObjects/Struct/CacheVector.cs index db36a5b..bc53125 100644 --- a/src/CachedObjects/Struct/CacheVector.cs +++ b/src/CachedObjects/Struct/CacheVector.cs @@ -70,21 +70,21 @@ namespace Explorer { if (!IsExpanded) { - if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("v", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = true; } } else { - if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) + if (GUIUnstrip.Button("^", new GUILayoutOption[] { GUILayout.Width(25) })) { IsExpanded = false; } } } - GUILayout.Label($"Vector{VectorSize}: {(string)m_toStringMethod.Invoke(Value, new object[0])}", null); + GUIUnstrip.Label($"Vector{VectorSize}: {(string)m_toStringMethod.Invoke(Value, new object[0])}"); if (CanWrite && IsExpanded) { @@ -95,14 +95,14 @@ namespace Explorer // always draw x and y GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); - x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); + x = GUIUnstrip.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); - y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); + y = GUIUnstrip.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); if (VectorSize > 2) @@ -110,8 +110,8 @@ namespace Explorer // draw z GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); - z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); + z = GUIUnstrip.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); } if (VectorSize > 3) @@ -119,15 +119,15 @@ namespace Explorer // draw w GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); - w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); + w = GUIUnstrip.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); GUIUnstrip.EndHorizontal(); } // draw set value button GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); - if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) + if (GUIUnstrip.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } diff --git a/src/CppExplorer.cs b/src/CppExplorer.cs index db1b5d2..90433f7 100644 --- a/src/CppExplorer.cs +++ b/src/CppExplorer.cs @@ -13,7 +13,7 @@ namespace Explorer public class CppExplorer : MelonMod { public const string NAME = "CppExplorer"; - public const string VERSION = "1.7.1"; + public const string VERSION = "1.7.2"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.cppexplorer"; diff --git a/src/CppExplorer.csproj b/src/CppExplorer.csproj index 4284eda..d11d9eb 100644 --- a/src/CppExplorer.csproj +++ b/src/CppExplorer.csproj @@ -101,7 +101,7 @@ - + diff --git a/src/Helpers/PageHelper.cs b/src/Helpers/PageHelper.cs index 1f22de2..20a5995 100644 --- a/src/Helpers/PageHelper.cs +++ b/src/Helpers/PageHelper.cs @@ -51,7 +51,7 @@ namespace Explorer var orig = GUI.skin.label.alignment; GUI.skin.label.alignment = TextAnchor.MiddleCenter; - GUILayout.Label($"Page {PageOffset + 1}/{MaxPageOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) }); + GUIUnstrip.Label($"Page {PageOffset + 1}/{MaxPageOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) }); GUI.skin.label.alignment = orig; } @@ -97,9 +97,9 @@ namespace Explorer public void DrawLimitInputArea() { - GUILayout.Label("Limit: ", new GUILayoutOption[] { GUILayout.Width(50) }); + GUIUnstrip.Label("Limit: ", new GUILayoutOption[] { GUILayout.Width(50) }); var limit = this.ItemsPerPage.ToString(); - limit = GUILayout.TextField(limit, new GUILayoutOption[] { GUILayout.Width(50) }); + limit = GUIUnstrip.TextField(limit, new GUILayoutOption[] { GUILayout.Width(50) }); if (limit != ItemsPerPage.ToString() && int.TryParse(limit, out int i)) { ItemsPerPage = i; diff --git a/src/Menu/MainMenu/MainMenu.cs b/src/Menu/MainMenu/MainMenu.cs index 3750529..0081db2 100644 --- a/src/Menu/MainMenu/MainMenu.cs +++ b/src/Menu/MainMenu/MainMenu.cs @@ -91,7 +91,7 @@ namespace Explorer else GUI.color = Color.white; - if (GUILayout.Button(Pages[i].Name, null)) + if (GUIUnstrip.Button(Pages[i].Name)) { m_currentPage = i; } @@ -100,13 +100,13 @@ namespace Explorer GUIUnstrip.BeginHorizontal(); GUI.color = Color.white; - InspectUnderMouse.EnableInspect = GUILayout.Toggle(InspectUnderMouse.EnableInspect, "Inspect Under Mouse (Shift + RMB)", null); + InspectUnderMouse.EnableInspect = GUIUnstrip.Toggle(InspectUnderMouse.EnableInspect, "Inspect Under Mouse (Shift + RMB)"); bool mouseState = CursorControl.ForceUnlockMouse; - bool setMouse = GUILayout.Toggle(mouseState, "Force Unlock Mouse (Left Alt)", null); + bool setMouse = GUIUnstrip.Toggle(mouseState, "Force Unlock Mouse (Left Alt)"); if (setMouse != mouseState) CursorControl.ForceUnlockMouse = setMouse; - WindowManager.TabView = GUILayout.Toggle(WindowManager.TabView, "Tab View", null); + WindowManager.TabView = GUIUnstrip.Toggle(WindowManager.TabView, "Tab View"); GUIUnstrip.EndHorizontal(); //GUIUnstrip.Space(10); diff --git a/src/Menu/MainMenu/Pages/ConsolePage.cs b/src/Menu/MainMenu/Pages/ConsolePage.cs index d3448c2..706bcc3 100644 --- a/src/Menu/MainMenu/Pages/ConsolePage.cs +++ b/src/Menu/MainMenu/Pages/ConsolePage.cs @@ -123,19 +123,19 @@ MelonLogger.Log(""hello world"");"; public override void DrawWindow() { - GUILayout.Label("C# REPL Console", null); + GUIUnstrip.Label("C# REPL Console"); GUI.skin.label.alignment = TextAnchor.UpperLeft; - GUILayout.Label("Enter code here as though it is a method body:", null); + GUIUnstrip.Label("Enter code here as though it is a method body:"); inputAreaScroll = GUIUnstrip.BeginScrollView(inputAreaScroll, new GUILayoutOption[] { GUILayout.Height(250) }); - MethodInput = GUILayout.TextArea(MethodInput, new GUILayoutOption[] { GUILayout.ExpandHeight(true) }); + MethodInput = GUIUnstrip.TextArea(MethodInput, new GUILayoutOption[] { GUILayout.ExpandHeight(true) }); GUIUnstrip.EndScrollView(); - if (GUILayout.Button("Execute", null)) + if (GUIUnstrip.Button("Execute")) { try { @@ -157,16 +157,16 @@ MelonLogger.Log(""hello world"");"; } } - GUILayout.Label("Using directives:", null); + GUIUnstrip.Label("Using directives:"); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Add namespace:", new GUILayoutOption[] { GUILayout.Width(105) }); - UsingInput = GUILayout.TextField(UsingInput, new GUILayoutOption[] { GUILayout.Width(150) }); - if (GUILayout.Button("Add", new GUILayoutOption[] { GUILayout.Width(120) })) + GUIUnstrip.Label("Add namespace:", new GUILayoutOption[] { GUILayout.Width(105) }); + UsingInput = GUIUnstrip.TextField(UsingInput, new GUILayoutOption[] { GUILayout.Width(150) }); + if (GUIUnstrip.Button("Add", new GUILayoutOption[] { GUILayout.Width(120) })) { AddUsing(UsingInput); } - if (GUILayout.Button("Clear All", new GUILayoutOption[] { GUILayout.Width(120) })) + if (GUIUnstrip.Button("Clear All", new GUILayoutOption[] { GUILayout.Width(120) })) { ResetConsole(); } @@ -174,7 +174,7 @@ MelonLogger.Log(""hello world"");"; foreach (var asm in UsingDirectives) { - GUILayout.Label(AsmToUsing(asm, true), null); + GUIUnstrip.Label(AsmToUsing(asm, true)); } } diff --git a/src/Menu/MainMenu/Pages/ScenePage.cs b/src/Menu/MainMenu/Pages/ScenePage.cs index a871103..bd39d68 100644 --- a/src/Menu/MainMenu/Pages/ScenePage.cs +++ b/src/Menu/MainMenu/Pages/ScenePage.cs @@ -226,19 +226,19 @@ namespace Explorer GUIUnstrip.BeginHorizontal(); // Current Scene label - GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) }); + GUIUnstrip.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) }); SceneChangeButtons(); - GUILayout.Label("" + m_currentScene + "", null); //new GUILayoutOption[] { GUILayout.Width(250) }); + GUIUnstrip.Label("" + m_currentScene + ""); GUIUnstrip.EndHorizontal(); // ----- GameObject Search ----- GUIUnstrip.BeginHorizontal(GUI.skin.box, null); - GUILayout.Label("Search Scene:", new GUILayoutOption[] { GUILayout.Width(100) }); + GUIUnstrip.Label("Search Scene:", new GUILayoutOption[] { GUILayout.Width(100) }); - m_searchInput = GUILayout.TextField(m_searchInput, null); + m_searchInput = GUIUnstrip.TextField(m_searchInput); - if (GUILayout.Button("Search", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("Search", new GUILayoutOption[] { GUILayout.Width(80) })) { Search(); } @@ -255,11 +255,11 @@ namespace Explorer if (scenes.Count > 1) { int changeWanted = 0; - if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) })) + if (GUIUnstrip.Button("<", new GUILayoutOption[] { GUILayout.Width(30) })) { changeWanted = -1; } - if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(30) })) + if (GUIUnstrip.Button(">", new GUILayoutOption[] { GUILayout.Width(30) })) { changeWanted = 1; } @@ -288,7 +288,7 @@ namespace Explorer if (Pages.ItemCount > Pages.ItemsPerPage) { - if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) { Pages.TurnPage(Turn.Left, ref this.scroll); @@ -297,7 +297,7 @@ namespace Explorer Pages.CurrentPageLabel(); - if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) { Pages.TurnPage(Turn.Right, ref this.scroll); @@ -314,13 +314,13 @@ namespace Explorer if (m_currentTransform != null) { GUIUnstrip.BeginHorizontal(); - if (GUILayout.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) })) + if (GUIUnstrip.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) })) { TraverseUp(); } else { - GUILayout.Label("" + m_currentTransform.GetGameObjectPath() + "", + GUIUnstrip.Label("" + m_currentTransform.GetGameObjectPath() + "", new GUILayoutOption[] { GUILayout.Width(MainMenu.MainRect.width - 187f) }); } @@ -330,11 +330,11 @@ namespace Explorer } else { - GUILayout.Label("Scene Root GameObjects:", null); + GUIUnstrip.Label("Scene Root GameObjects:"); if (m_getRootObjectsFailed) { - if (GUILayout.Button("Update Root Object List (auto-update failed!)", null)) + if (GUIUnstrip.Button("Update Root Object List (auto-update failed!)")) { Update_Impl(true); } @@ -359,7 +359,7 @@ namespace Explorer } label += ""; - GUILayout.Label(label, null); + GUIUnstrip.Label(label); } else { @@ -377,12 +377,12 @@ namespace Explorer private void DrawSearchResultsList() { - if (GUILayout.Button("<- Cancel Search", new GUILayoutOption[] { GUILayout.Width(150) })) + if (GUIUnstrip.Button("<- Cancel Search", new GUILayoutOption[] { GUILayout.Width(150) })) { CancelSearch(); } - GUILayout.Label("Search Results:", null); + GUIUnstrip.Label("Search Results:"); if (m_searchResults.Count > 0) { @@ -404,13 +404,13 @@ namespace Explorer } else { - GUILayout.Label("Null or destroyed!", null); + GUIUnstrip.Label("Null or destroyed!"); } } } else { - GUILayout.Label("No results found!", null); + GUIUnstrip.Label("No results found!"); } } diff --git a/src/Menu/MainMenu/Pages/SearchPage.cs b/src/Menu/MainMenu/Pages/SearchPage.cs index d18542c..7d08cb5 100644 --- a/src/Menu/MainMenu/Pages/SearchPage.cs +++ b/src/Menu/MainMenu/Pages/SearchPage.cs @@ -85,8 +85,8 @@ namespace Explorer { // helpers GUIUnstrip.BeginHorizontal(GUI.skin.box, null); - GUILayout.Label("Helpers", new GUILayoutOption[] { GUILayout.Width(70) }); - if (GUILayout.Button("Find Static Instances", new GUILayoutOption[] { GUILayout.Width(180) })) + GUIUnstrip.Label("Helpers", new GUILayoutOption[] { GUILayout.Width(70) }); + if (GUIUnstrip.Button("Find Static Instances", new GUILayoutOption[] { GUILayout.Width(180) })) { //m_searchResults = GetInstanceClassScanner().ToList(); CacheResults(GetInstanceClassScanner()); @@ -100,7 +100,7 @@ namespace Explorer GUIUnstrip.BeginVertical(GUI.skin.box, null); GUI.skin.label.alignment = TextAnchor.MiddleCenter; - GUILayout.Label("Results " + " (" + m_searchResults.Count + ")", null); + GUIUnstrip.Label("Results " + " (" + m_searchResults.Count + ")"); GUI.skin.label.alignment = TextAnchor.UpperLeft; int count = m_searchResults.Count; @@ -115,14 +115,14 @@ namespace Explorer if (Pages.ItemCount > Pages.ItemsPerPage) { - if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) { Pages.TurnPage(Turn.Left, ref this.resultsScroll); } Pages.CurrentPageLabel(); - if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) { Pages.TurnPage(Turn.Right, ref this.resultsScroll); } @@ -146,7 +146,7 @@ namespace Explorer } else { - GUILayout.Label("No results found!", null); + GUIUnstrip.Label("No results found!"); } GUIUnstrip.EndScrollView(); @@ -164,19 +164,19 @@ namespace Explorer // ----- GameObject Search ----- GUI.skin.label.alignment = TextAnchor.MiddleCenter; - GUILayout.Label("Search", null); + GUIUnstrip.Label("Search"); GUI.skin.label.alignment = TextAnchor.UpperLeft; GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Name Contains:", new GUILayoutOption[] { GUILayout.Width(100) }); - m_searchInput = GUILayout.TextField(m_searchInput, new GUILayoutOption[] { GUILayout.Width(200) }); + GUIUnstrip.Label("Name Contains:", new GUILayoutOption[] { GUILayout.Width(100) }); + m_searchInput = GUIUnstrip.TextField(m_searchInput, new GUILayoutOption[] { GUILayout.Width(200) }); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Class Filter:", new GUILayoutOption[] { GUILayout.Width(100) }); + GUIUnstrip.Label("Class Filter:", new GUILayoutOption[] { GUILayout.Width(100) }); ClassFilterToggle(TypeFilter.Object, "Object"); ClassFilterToggle(TypeFilter.GameObject, "GameObject"); ClassFilterToggle(TypeFilter.Component, "Component"); @@ -186,21 +186,21 @@ namespace Explorer { GUIUnstrip.BeginHorizontal(); GUI.skin.label.alignment = TextAnchor.MiddleRight; - GUILayout.Label("Custom Class:", new GUILayoutOption[] { GUILayout.Width(250) }); + GUIUnstrip.Label("Custom Class:", new GUILayoutOption[] { GUILayout.Width(250) }); GUI.skin.label.alignment = TextAnchor.UpperLeft; - m_typeInput = GUILayout.TextField(m_typeInput, new GUILayoutOption[] { GUILayout.Width(250) }); + m_typeInput = GUIUnstrip.TextField(m_typeInput, new GUILayoutOption[] { GUILayout.Width(250) }); GUIUnstrip.EndHorizontal(); } GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Scene Filter:", new GUILayoutOption[] { GUILayout.Width(100) }); + GUIUnstrip.Label("Scene Filter:", new GUILayoutOption[] { GUILayout.Width(100) }); SceneFilterToggle(SceneFilter.Any, "Any", 60); SceneFilterToggle(SceneFilter.This, "This Scene", 100); SceneFilterToggle(SceneFilter.DontDestroy, "DontDestroyOnLoad", 140); SceneFilterToggle(SceneFilter.None, "No Scene", 80); GUIUnstrip.EndHorizontal(); - if (GUILayout.Button("Search", null)) + if (GUIUnstrip.Button("Search")) { Search(); } @@ -218,7 +218,7 @@ namespace Explorer { GUI.color = Color.white; } - if (GUILayout.Button(label, new GUILayoutOption[] { GUILayout.Width(100) })) + if (GUIUnstrip.Button(label, new GUILayoutOption[] { GUILayout.Width(100) })) { TypeMode = mode; } @@ -235,7 +235,7 @@ namespace Explorer { GUI.color = Color.white; } - if (GUILayout.Button(label, new GUILayoutOption[] { GUILayout.Width(width) })) + if (GUIUnstrip.Button(label, new GUILayoutOption[] { GUILayout.Width(width) })) { SceneMode = mode; } diff --git a/src/Helpers/UIHelpers.cs b/src/Menu/UIHelpers.cs similarity index 87% rename from src/Helpers/UIHelpers.cs rename to src/Menu/UIHelpers.cs index 552f2ed..f536b0d 100644 --- a/src/Helpers/UIHelpers.cs +++ b/src/Menu/UIHelpers.cs @@ -15,7 +15,7 @@ namespace Explorer // helper for "Instantiate" button on UnityEngine.Objects public static void InstantiateButton(Object obj, float width = 100) { - if (GUILayout.Button("Instantiate", new GUILayoutOption[] { GUILayout.Width(width) })) + if (GUIUnstrip.Button("Instantiate", new GUILayoutOption[] { GUILayout.Width(width) })) { var newobj = Object.Instantiate(obj); @@ -62,7 +62,7 @@ namespace Explorer if (!obj) { - GUILayout.Label("null", null); + GUIUnstrip.Label("null"); return; } @@ -73,7 +73,7 @@ namespace Explorer GUI.color = activeColor; - enabled = GUILayout.Toggle(enabled, "", new GUILayoutOption[] { GUILayout.Width(18) }); + enabled = GUIUnstrip.Toggle(enabled, "", new GUILayoutOption[] { GUILayout.Width(18) }); if (obj.activeSelf != enabled) { obj.SetActive(enabled); @@ -81,7 +81,7 @@ namespace Explorer // ------- actual button --------- - if (GUILayout.Button(label, new GUILayoutOption[] { GUILayout.Height(22), GUILayout.Width(width) })) + if (GUIUnstrip.Button(label, new GUILayoutOption[] { GUILayout.Height(22), GUILayout.Width(width) })) { if (specialInspectMethod != null) { @@ -108,7 +108,7 @@ namespace Explorer public static void SmallInspectButton(object obj) { - if (GUILayout.Button("Inspect", null)) + if (GUIUnstrip.Button("Inspect")) { WindowManager.InspectObject(obj, out bool _); } diff --git a/src/Menu/UIStyles.cs b/src/Menu/UIStyles.cs index 4af7df4..864e51f 100644 --- a/src/Menu/UIStyles.cs +++ b/src/Menu/UIStyles.cs @@ -38,7 +38,7 @@ namespace Explorer var orig = GUI.color; GUI.color = _color; - GUILayout.Box(GUIContent.none, !small ? HorizontalBar : HorizontalBarSmall, null); + GUIUnstrip.Box(GUIContent.none, !small ? HorizontalBar : HorizontalBarSmall, null); GUI.color = orig; } diff --git a/src/Menu/Windows/GameObjectWindow.cs b/src/Menu/Windows/GameObjectWindow.cs index 9f7216d..71866fe 100644 --- a/src/Menu/Windows/GameObjectWindow.cs +++ b/src/Menu/Windows/GameObjectWindow.cs @@ -17,7 +17,7 @@ namespace Explorer public GameObject TargetGO; - private bool m_hideControls; + private static bool m_hideControls; // gui element holders private string m_name; @@ -218,37 +218,37 @@ namespace Explorer scroll = GUIUnstrip.BeginScrollView(scroll); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Scene: " + (m_scene == "" ? "n/a" : m_scene) + "", null); + GUIUnstrip.Label("Scene: " + (m_scene == "" ? "n/a" : m_scene) + ""); if (m_scene == UnityHelpers.ActiveSceneName) { - if (GUILayout.Button("Send to Scene View", new GUILayoutOption[] { GUILayout.Width(150) })) + if (GUIUnstrip.Button("Send to Scene View", new GUILayoutOption[] { GUILayout.Width(150) })) { ScenePage.Instance.SetTransformTarget(TargetGO.transform); MainMenu.SetCurrentPage(0); } } - if (GUILayout.Button("Reflection Inspect", new GUILayoutOption[] { GUILayout.Width(150) })) + if (GUIUnstrip.Button("Reflection Inspect", new GUILayoutOption[] { GUILayout.Width(150) })) { WindowManager.InspectObject(Target, out _, true); } GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Path:", new GUILayoutOption[] { GUILayout.Width(50) }); + GUIUnstrip.Label("Path:", new GUILayoutOption[] { GUILayout.Width(50) }); string pathlabel = TargetGO.transform.GetGameObjectPath(); if (TargetGO.transform.parent != null) { - if (GUILayout.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) })) + if (GUIUnstrip.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) })) { InspectGameObject(TargetGO.transform.parent); } } - GUILayout.TextArea(pathlabel, null); + GUIUnstrip.TextArea(pathlabel); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Name:", new GUILayoutOption[] { GUILayout.Width(50) }); - GUILayout.TextArea(m_name, null); + GUIUnstrip.Label("Name:", new GUILayoutOption[] { GUILayout.Width(50) }); + GUIUnstrip.TextArea(m_name); GUIUnstrip.EndHorizontal(); // --- Horizontal Columns section --- @@ -286,7 +286,7 @@ namespace Explorer GUIUnstrip.BeginVertical(GUI.skin.box, null); m_transformScroll = GUIUnstrip.BeginScrollView(m_transformScroll); - GUILayout.Label("Children", null); + GUIUnstrip.Label("Children"); GUIUnstrip.BeginHorizontal(); ChildPages.DrawLimitInputArea(); @@ -298,11 +298,11 @@ namespace Explorer GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) { ChildPages.TurnPage(Turn.Left, ref this.m_transformScroll); } - if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) { ChildPages.TurnPage(Turn.Right, ref this.m_transformScroll); } @@ -319,7 +319,7 @@ namespace Explorer if (!obj) { - GUILayout.Label("null", null); + GUIUnstrip.Label("null"); continue; } @@ -328,7 +328,7 @@ namespace Explorer } else { - GUILayout.Label("None", null); + GUIUnstrip.Label("None"); } GUIUnstrip.EndScrollView(); @@ -339,7 +339,7 @@ namespace Explorer { GUIUnstrip.BeginVertical(GUI.skin.box, null); m_compScroll = GUIUnstrip.BeginScrollView(m_compScroll); - GUILayout.Label("Components", null); + GUIUnstrip.Label("Components"); GUIUnstrip.BeginHorizontal(); CompPages.DrawLimitInputArea(); @@ -351,11 +351,11 @@ namespace Explorer GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) { CompPages.TurnPage(Turn.Left, ref this.m_compScroll); } - if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) { CompPages.TurnPage(Turn.Right, ref this.m_compScroll); } @@ -363,8 +363,9 @@ namespace Explorer GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - m_addComponentInput = GUILayout.TextField(m_addComponentInput, new GUILayoutOption[] { GUILayout.Width(130) }); - if (GUILayout.Button("Add Comp", null)) + var width = m_rect.width / 2 - 115f; + m_addComponentInput = GUIUnstrip.TextField(m_addComponentInput, new GUILayoutOption[] { GUILayout.Width(width) }); + if (GUIUnstrip.Button("Add Comp")) { if (ReflectionHelpers.GetTypeByName(m_addComponentInput) is Type compType) { @@ -411,11 +412,11 @@ namespace Explorer { GUIUnstrip.Space(26); } - if (GUILayout.Button("" + ilType.Name + "", new GUILayoutOption[] { GUILayout.Width(m_rect.width / 2 - 100) })) + if (GUIUnstrip.Button("" + ilType.Name + "", new GUILayoutOption[] { GUILayout.Width(m_rect.width / 2 - 100) })) { ReflectObject(component); } - if (GUILayout.Button("-", new GUILayoutOption[] { GUILayout.Width(20) })) + if (GUIUnstrip.Button("-", new GUILayoutOption[] { GUILayout.Width(20) })) { m_cachedDestroyList.Add(component); } @@ -453,7 +454,7 @@ namespace Explorer // ------ toggle active button ------ - _enabled = GUILayout.Toggle(_enabled, "", new GUILayoutOption[] { GUILayout.Width(18) }); + _enabled = GUIUnstrip.Toggle(_enabled, "", new GUILayoutOption[] { GUILayout.Width(18) }); if (obj.enabled != _enabled) { obj.enabled = _enabled; @@ -466,8 +467,8 @@ namespace Explorer if (m_hideControls) { GUIUnstrip.BeginHorizontal(); - GUILayout.Label("GameObject Controls", new GUILayoutOption[] { GUILayout.Width(200) }); - if (GUILayout.Button("^ Show ^", new GUILayoutOption[] { GUILayout.Width(75) })) + GUIUnstrip.Label("GameObject Controls", new GUILayoutOption[] { GUILayout.Width(200) }); + if (GUIUnstrip.Button("^ Show ^", new GUILayoutOption[] { GUILayout.Width(75) })) { m_hideControls = false; } @@ -479,8 +480,8 @@ namespace Explorer GUIUnstrip.BeginVertical(GUI.skin.box, new GUILayoutOption[] { GUILayout.Width(520) }); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("GameObject Controls", new GUILayoutOption[] { GUILayout.Width(200) }); - if (GUILayout.Button("v Hide v", new GUILayoutOption[] { GUILayout.Width(75) })) + GUIUnstrip.Label("GameObject Controls", new GUILayoutOption[] { GUILayout.Width(200) }); + if (GUIUnstrip.Button("v Hide v", new GUILayoutOption[] { GUILayout.Width(75) })) { m_hideControls = true; } @@ -488,20 +489,20 @@ namespace Explorer GUIUnstrip.BeginHorizontal(); bool m_active = TargetGO.activeSelf; - m_active = GUILayout.Toggle(m_active, (m_active ? "Enabled " : "Disabled") + "", + m_active = GUIUnstrip.Toggle(m_active, (m_active ? "Enabled " : "Disabled") + "", new GUILayoutOption[] { GUILayout.Width(80) }); if (TargetGO.activeSelf != m_active) { TargetGO.SetActive(m_active); } UIHelpers.InstantiateButton(TargetGO, 100); - if (GUILayout.Button("Set DontDestroyOnLoad", new GUILayoutOption[] { GUILayout.Width(170) })) + if (GUIUnstrip.Button("Set DontDestroyOnLoad", new GUILayoutOption[] { GUILayout.Width(170) })) { GameObject.DontDestroyOnLoad(TargetGO); TargetGO.hideFlags |= HideFlags.DontUnloadUnusedAsset; } var lbl = m_freeze ? "Unfreeze" : "Freeze Pos/Rot"; - if (GUILayout.Button(lbl, new GUILayoutOption[] { GUILayout.Width(110) })) + if (GUIUnstrip.Button(lbl, new GUILayoutOption[] { GUILayout.Width(110) })) { m_freeze = !m_freeze; if (m_freeze) @@ -513,8 +514,8 @@ namespace Explorer GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - m_setParentInput = GUILayout.TextField(m_setParentInput, null); - if (GUILayout.Button("Set Parent", new GUILayoutOption[] { GUILayout.Width(80) })) + m_setParentInput = GUIUnstrip.TextField(m_setParentInput); + if (GUIUnstrip.Button("Set Parent", new GUILayoutOption[] { GUILayout.Width(80) })) { if (GameObject.Find(m_setParentInput) is GameObject newparent) { @@ -526,7 +527,7 @@ namespace Explorer } } - if (GUILayout.Button("Detach from parent", new GUILayoutOption[] { GUILayout.Width(160) })) + if (GUIUnstrip.Button("Detach from parent", new GUILayoutOption[] { GUILayout.Width(160) })) { TargetGO.transform.parent = null; } @@ -539,7 +540,7 @@ namespace Explorer m_cachedInput[2] = TranslateControl(TranslateType.Scale, ref m_scaleAmount, false); GUIUnstrip.BeginHorizontal(); - if (GUILayout.Button("Apply to Transform", null) || m_autoApplyTransform) + if (GUIUnstrip.Button("Apply to Transform") || m_autoApplyTransform) { if (m_localContext) { @@ -558,7 +559,7 @@ namespace Explorer UpdateFreeze(); } } - if (GUILayout.Button("Update from Transform", null) || m_autoUpdateTransform) + if (GUIUnstrip.Button("Update from Transform") || m_autoUpdateTransform) { CacheTransformValues(); } @@ -570,7 +571,7 @@ namespace Explorer GUIUnstrip.EndHorizontal(); bool b = m_localContext; - b = GUILayout.Toggle(b, "Use local transform values?", null); + b = GUIUnstrip.Toggle(b, "Use local transform values?"); if (b != m_localContext) { m_localContext = b; @@ -583,7 +584,7 @@ namespace Explorer GUIUnstrip.EndVertical(); - if (GUILayout.Button("Destroy", new GUILayoutOption[] { GUILayout.Width(120) })) + if (GUIUnstrip.Button("Destroy", new GUILayoutOption[] { GUILayout.Width(120) })) { GameObject.Destroy(TargetGO); DestroyWindow(); @@ -614,7 +615,7 @@ namespace Explorer lbl += value ? "lime" : "red"; lbl += $">{message}"; - value = GUILayout.Toggle(value, lbl, null); + value = GUIUnstrip.Toggle(value, lbl); } public enum TranslateType @@ -627,7 +628,7 @@ namespace Explorer private Vector3 TranslateControl(TranslateType mode, ref float amount, bool multByTime) { GUIUnstrip.BeginHorizontal(); - GUILayout.Label($"{(m_localContext ? "Local " : "")}{mode}:", + GUIUnstrip.Label($"{(m_localContext ? "Local " : "")}{mode}:", new GUILayoutOption[] { GUILayout.Width(m_localContext ? 110 : 65) }); var transform = TargetGO.transform; @@ -635,14 +636,14 @@ namespace Explorer { case TranslateType.Position: var pos = m_localContext ? transform.localPosition : transform.position; - GUILayout.Label(pos.ToString(), new GUILayoutOption[] { GUILayout.Width(250) }); + GUIUnstrip.Label(pos.ToString(), new GUILayoutOption[] { GUILayout.Width(250) }); break; case TranslateType.Rotation: var rot = m_localContext ? transform.localEulerAngles : transform.eulerAngles; - GUILayout.Label(rot.ToString(), new GUILayoutOption[] { GUILayout.Width(250) }); + GUIUnstrip.Label(rot.ToString(), new GUILayoutOption[] { GUILayout.Width(250) }); break; case TranslateType.Scale: - GUILayout.Label(transform.localScale.ToString(), new GUILayoutOption[] { GUILayout.Width(250) }); + GUIUnstrip.Label(transform.localScale.ToString(), new GUILayoutOption[] { GUILayout.Width(250) }); break; } GUIUnstrip.EndHorizontal(); @@ -652,18 +653,18 @@ namespace Explorer GUIUnstrip.BeginHorizontal(); GUI.skin.label.alignment = TextAnchor.MiddleRight; - GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(20) }); + GUIUnstrip.Label("X:", new GUILayoutOption[] { GUILayout.Width(20) }); PlusMinusFloat(ref input.x, amount, multByTime); - GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(20) }); + GUIUnstrip.Label("Y:", new GUILayoutOption[] { GUILayout.Width(20) }); PlusMinusFloat(ref input.y, amount, multByTime); - GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(20) }); + GUIUnstrip.Label("Z:", new GUILayoutOption[] { GUILayout.Width(20) }); PlusMinusFloat(ref input.z, amount, multByTime); - GUILayout.Label("+/-:", new GUILayoutOption[] { GUILayout.Width(30) }); + GUIUnstrip.Label("+/-:", new GUILayoutOption[] { GUILayout.Width(30) }); var amountInput = amount.ToString("F3"); - amountInput = GUILayout.TextField(amountInput, new GUILayoutOption[] { GUILayout.Width(60) }); + amountInput = GUIUnstrip.TextField(amountInput, new GUILayoutOption[] { GUILayout.Width(60) }); if (float.TryParse(amountInput, out float f)) { amount = f; @@ -678,16 +679,16 @@ namespace Explorer private void PlusMinusFloat(ref float f, float amount, bool multByTime) { string s = f.ToString("F3"); - s = GUILayout.TextField(s, new GUILayoutOption[] { GUILayout.Width(60) }); + s = GUIUnstrip.TextField(s, new GUILayoutOption[] { GUILayout.Width(60) }); if (float.TryParse(s, out float f2)) { f = f2; } - if (GUILayout.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) })) + if (GUIUnstrip.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) })) { f -= multByTime ? amount * Time.deltaTime : amount; } - if (GUILayout.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) })) + if (GUIUnstrip.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) })) { f += multByTime ? amount * Time.deltaTime : amount; } diff --git a/src/Menu/Windows/ReflectionWindow.cs b/src/Menu/Windows/ReflectionWindow.cs index c8b7a17..2425838 100644 --- a/src/Menu/Windows/ReflectionWindow.cs +++ b/src/Menu/Windows/ReflectionWindow.cs @@ -236,26 +236,26 @@ namespace Explorer } GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Type: " + TargetType.FullName + "", new GUILayoutOption[] { GUILayout.Width(245f) }); + GUIUnstrip.Label("Type: " + TargetType.FullName + "", new GUILayoutOption[] { GUILayout.Width(245f) }); if (m_uObj) { - GUILayout.Label("Name: " + m_uObj.name, null); + GUIUnstrip.Label("Name: " + m_uObj.name); } GUIUnstrip.EndHorizontal(); if (m_uObj) { GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Tools:", new GUILayoutOption[] { GUILayout.Width(80) }); + GUIUnstrip.Label("Tools:", new GUILayoutOption[] { GUILayout.Width(80) }); UIHelpers.InstantiateButton(m_uObj); if (m_component && m_component.gameObject is GameObject obj) { GUI.skin.label.alignment = TextAnchor.MiddleRight; - GUILayout.Label("GameObject:", new GUILayoutOption[] { GUILayout.Width(135) }); + GUIUnstrip.Label("GameObject:", new GUILayoutOption[] { GUILayout.Width(135) }); var charWidth = obj.name.Length * 15; var maxWidth = rect.width - 350; var labelWidth = charWidth < maxWidth ? charWidth : maxWidth; - if (GUILayout.Button("" + obj.name + "", new GUILayoutOption[] { GUILayout.Width(labelWidth) })) + if (GUIUnstrip.Button("" + obj.name + "", new GUILayoutOption[] { GUILayout.Width(labelWidth) })) { WindowManager.InspectObject(obj, out bool _); } @@ -267,12 +267,12 @@ namespace Explorer UIStyles.HorizontalLine(Color.grey); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Search:", new GUILayoutOption[] { GUILayout.Width(75) }); - m_search = GUILayout.TextField(m_search, null); + GUIUnstrip.Label("Search:", new GUILayoutOption[] { GUILayout.Width(75) }); + m_search = GUIUnstrip.TextField(m_search); GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Filter:", new GUILayoutOption[] { GUILayout.Width(75) }); + GUIUnstrip.Label("Filter:", new GUILayoutOption[] { GUILayout.Width(75) }); FilterToggle(MemberTypes.All, "All"); FilterToggle(MemberTypes.Property, "Properties"); FilterToggle(MemberTypes.Field, "Fields"); @@ -280,15 +280,15 @@ namespace Explorer GUIUnstrip.EndHorizontal(); GUIUnstrip.BeginHorizontal(); - GUILayout.Label("Values:", new GUILayoutOption[] { GUILayout.Width(75) }); - if (GUILayout.Button("Update", new GUILayoutOption[] { GUILayout.Width(100) })) + GUIUnstrip.Label("Values:", new GUILayoutOption[] { GUILayout.Width(75) }); + if (GUIUnstrip.Button("Update", new GUILayoutOption[] { GUILayout.Width(100) })) { UpdateValues(); } GUI.color = m_autoUpdate ? Color.green : Color.red; - m_autoUpdate = GUILayout.Toggle(m_autoUpdate, "Auto-update?", new GUILayoutOption[] { GUILayout.Width(100) }); + m_autoUpdate = GUIUnstrip.Toggle(m_autoUpdate, "Auto-update?", new GUILayoutOption[] { GUILayout.Width(100) }); GUI.color = m_hideFailedReflection ? Color.green : Color.red; - m_hideFailedReflection = GUILayout.Toggle(m_hideFailedReflection, "Hide failed Reflection?", new GUILayoutOption[] { GUILayout.Width(150) }); + m_hideFailedReflection = GUIUnstrip.Toggle(m_hideFailedReflection, "Hide failed Reflection?", new GUILayoutOption[] { GUILayout.Width(150) }); GUI.color = Color.white; GUIUnstrip.EndHorizontal(); @@ -303,14 +303,14 @@ namespace Explorer if (Pages.ItemCount > Pages.ItemsPerPage) { - if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) { Pages.TurnPage(Turn.Left, ref this.scroll); } Pages.CurrentPageLabel(); - if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) + if (GUIUnstrip.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) { Pages.TurnPage(Turn.Right, ref this.scroll); } @@ -386,7 +386,7 @@ namespace Explorer { GUI.color = Color.white; } - if (GUILayout.Button(label, new GUILayoutOption[] { GUILayout.Width(100) })) + if (GUIUnstrip.Button(label, new GUILayoutOption[] { GUILayout.Width(100) })) { m_filter = mode; Pages.PageOffset = 0; diff --git a/src/Menu/Windows/ResizeDrag.cs b/src/Menu/Windows/ResizeDrag.cs index 5265265..0d9105f 100644 --- a/src/Menu/Windows/ResizeDrag.cs +++ b/src/Menu/Windows/ResizeDrag.cs @@ -29,14 +29,14 @@ namespace Explorer GUIUnstrip.BeginHorizontal(GUI.skin.box, null); GUI.skin.label.alignment = TextAnchor.MiddleCenter; - GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) }); + GUIUnstrip.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) }); //var r = GUILayoutUtility.GetLastRect(); var r = LayoutUtilityUnstrip.GetLastRect(); var mousePos = InputHelper.mousePosition; - Vector2 mouse = GUIUtility.ScreenToGUIPoint(new Vector2(mousePos.x, Screen.height - mousePos.y)); + var mouse = GUIUnstrip.ScreenToGUIPoint(new Vector2(mousePos.x, Screen.height - mousePos.y)); if (r.Contains(mouse) && InputHelper.GetMouseButtonDown(0)) { @@ -78,24 +78,24 @@ namespace Explorer { GUIUnstrip.BeginHorizontal(GUI.skin.box, null); - GUILayout.Label("Resize window:", new GUILayoutOption[] { GUILayout.Width(100) }); + GUIUnstrip.Label("Resize window:", new GUILayoutOption[] { GUILayout.Width(100) }); GUI.skin.label.alignment = TextAnchor.MiddleRight; - GUILayout.Label("Width:", new GUILayoutOption[] { GUILayout.Width(60) }); - if (GUILayout.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) })) + GUIUnstrip.Label("Width:", new GUILayoutOption[] { GUILayout.Width(60) }); + if (GUIUnstrip.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) })) { _rect.width -= 5f; } - if (GUILayout.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) })) + if (GUIUnstrip.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) })) { _rect.width += 5f; } - GUILayout.Label("Height:", new GUILayoutOption[] { GUILayout.Width(60) }); - if (GUILayout.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) })) + GUIUnstrip.Label("Height:", new GUILayoutOption[] { GUILayout.Width(60) }); + if (GUIUnstrip.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) })) { _rect.height -= 5f; } - if (GUILayout.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) })) + if (GUIUnstrip.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) })) { _rect.height += 5f; } diff --git a/src/Menu/Windows/TabViewWindow.cs b/src/Menu/Windows/TabViewWindow.cs index bd798d1..fafe496 100644 --- a/src/Menu/Windows/TabViewWindow.cs +++ b/src/Menu/Windows/TabViewWindow.cs @@ -87,11 +87,11 @@ namespace Explorer GUI.color = focused ? Color.green : Color.white; var window = WindowManager.Windows[i]; - if (GUILayout.Button(color + window.Title + "", new GUILayoutOption[] { GUILayout.Width(200) })) + if (GUIUnstrip.Button(color + window.Title + "", new GUILayoutOption[] { GUILayout.Width(200) })) { TargetTabID = i; } - if (GUILayout.Button("X", new GUILayoutOption[] { GUILayout.Width(22) })) + if (GUIUnstrip.Button("X", new GUILayoutOption[] { GUILayout.Width(22) })) { window.DestroyWindow(); } diff --git a/src/UnstripFixes/GUIUnstrip.cs b/src/UnstripFixes/GUIUnstrip.cs index 1c8baf2..b413190 100644 --- a/src/UnstripFixes/GUIUnstrip.cs +++ b/src/UnstripFixes/GUIUnstrip.cs @@ -52,6 +52,19 @@ namespace Explorer return m_scrollStack; } + // ======== Fix for GUIUtility.ScreenToGuiPoint ======== + + public static Vector2 ScreenToGUIPoint(Vector2 screenPoint) + { + return GUIClip.ClipToWindow(InternalScreenToWindowPoint(screenPoint)); + } + + private static Vector2 InternalScreenToWindowPoint(Vector2 screenPoint) + { + GUIUtility.InternalScreenToWindowPoint_Injected(ref screenPoint, out Vector2 result); + return result; + } + // ================= Fix for Space ================= public static void Space(float pixels) @@ -220,7 +233,7 @@ namespace Explorer // Make a repeating button. The button returns true as long as the user holds down the mouse static public bool RepeatButton(GUIContent content, GUIStyle style, params GUILayoutOption[] options) { return DoRepeatButton(content, style, options); } static bool DoRepeatButton(GUIContent content, GUIStyle style, GUILayoutOption[] options) - { return GUI.RepeatButton(LayoutUtilityUnstrip.GetRect(content, style, options), content, style); } + { return RepeatButton(LayoutUtilityUnstrip.GetRect(content, style, options), content, style); } public static string TextField(string text, params GUILayoutOption[] options) { return DoTextField(text, -1, false, GUI.skin.textField, options); } public static string TextField(string text, int maxLength, params GUILayoutOption[] options) { return DoTextField(text, maxLength, false, GUI.skin.textField, options); } @@ -262,6 +275,72 @@ namespace Explorer static bool DoToggle(bool value, GUIContent content, GUIStyle style, GUILayoutOption[] options) { return GUI.Toggle(LayoutUtilityUnstrip.GetRect(content, style, options), value, content, style); } + // =========== Fix for GUI.RepeatButton (not GUILayout) =========== + + public static bool RepeatButton(Rect position, string text) + { + return DoRepeatButton(position, GUIContent.Temp(text), GUI.s_Skin.button, FocusType.Passive); + } + + public static bool RepeatButton(Rect position, Texture image) + { + return DoRepeatButton(position, GUIContent.Temp(image), GUI.s_Skin.button, FocusType.Passive); + } + + public static bool RepeatButton(Rect position, GUIContent content) + { + return DoRepeatButton(position, content, GUI.s_Skin.button, FocusType.Passive); + } + + public static bool RepeatButton(Rect position, string text, GUIStyle style) + { + return DoRepeatButton(position, GUIContent.Temp(text), style, FocusType.Passive); + } + + public static bool RepeatButton(Rect position, Texture image, GUIStyle style) + { + return DoRepeatButton(position, GUIContent.Temp(image), style, FocusType.Passive); + } + + public static bool RepeatButton(Rect position, GUIContent content, GUIStyle style) + { + return DoRepeatButton(position, content, style, FocusType.Passive); + } + + private static bool DoRepeatButton(Rect position, GUIContent content, GUIStyle style, FocusType focusType) + { + int id = GUIUtility.GetControlID(GUI.s_RepeatButtonHash, focusType, position); + switch (Event.current.GetTypeForControl(id)) + { + case EventType.MouseDown: + // If the mouse is inside the button, we say that we're the hot control + if (position.Contains(Event.current.mousePosition)) + { + GUIUtility.hotControl = id; + Event.current.Use(); + } + return false; + case EventType.MouseUp: + if (GUIUtility.hotControl == id) + { + GUIUtility.hotControl = 0; + + // If we got the mousedown, the mouseup is ours as well + // (no matter if the click was in the button or not) + Event.current.Use(); + + // But we only return true if the button was actually clicked + return position.Contains(Event.current.mousePosition); + } + return false; + case EventType.Repaint: + style.Draw(position, content, id, false, position.Contains(Event.current.mousePosition)); + return id == GUIUtility.hotControl && position.Contains(Event.current.mousePosition); + } + return false; + } + + // ================= Fix for BeginScrollView. ======================= public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options) @@ -271,7 +350,7 @@ namespace Explorer { try { - return GUILayout.BeginScrollView(scroll, options); + return GUIUnstrip.BeginScrollView(scroll, options); } catch { @@ -303,7 +382,7 @@ namespace Explorer if (!ScrollFailed) { - GUILayout.EndScrollView(); + GUIUnstrip.EndScrollView(); } else if (!ManualUnstripFailed) {