diff --git a/src/CachedObjects/CacheObjectBase.cs b/src/CachedObjects/CacheObjectBase.cs index 5f569d3..f47ef83 100644 --- a/src/CachedObjects/CacheObjectBase.cs +++ b/src/CachedObjects/CacheObjectBase.cs @@ -390,7 +390,7 @@ namespace Explorer if (HasParameters) { - GUILayout.BeginVertical(null); + GUIUnstrip.BeginVertical(); if (m_isEvaluating) { @@ -406,16 +406,16 @@ namespace Explorer label = $"[{label} = {m_arguments[i].DefaultValue}]"; } - GUILayout.BeginHorizontal(null); + 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); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) })) { if (cm != null) @@ -431,7 +431,7 @@ namespace Explorer { m_isEvaluating = false; } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } else { @@ -441,16 +441,16 @@ namespace Explorer } } - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); // new line and space - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(labelWidth); } else if (cm != null) { - //GUILayout.BeginHorizontal(null); + //GUIUnstrip.BeginHorizontal(); if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) })) { @@ -458,8 +458,8 @@ namespace Explorer } // new line and space - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(labelWidth); } diff --git a/src/CachedObjects/Object/CacheDictionary.cs b/src/CachedObjects/Object/CacheDictionary.cs index 5fdedcf..7c6e0ec 100644 --- a/src/CachedObjects/Object/CacheDictionary.cs +++ b/src/CachedObjects/Object/CacheDictionary.cs @@ -243,8 +243,8 @@ namespace Explorer if (count > Pages.ItemsPerPage) { - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); @@ -273,8 +273,8 @@ namespace Explorer var val = m_cachedValues[i]; //collapsing the BeginHorizontal called from ReflectionWindow.WindowFunction or previous array entry - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); //GUIUnstrip.Space(whitespace); diff --git a/src/CachedObjects/Object/CacheList.cs b/src/CachedObjects/Object/CacheList.cs index d1a94b3..2f815dd 100644 --- a/src/CachedObjects/Object/CacheList.cs +++ b/src/CachedObjects/Object/CacheList.cs @@ -305,8 +305,8 @@ namespace Explorer if (count > Pages.ItemsPerPage) { - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); @@ -334,8 +334,8 @@ namespace Explorer var entry = m_cachedEntries[i]; //collapsing the BeginHorizontal called from ReflectionWindow.WindowFunction or previous array entry - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); diff --git a/src/CachedObjects/Struct/CacheColor.cs b/src/CachedObjects/Struct/CacheColor.cs index 26b2d0f..0301965 100644 --- a/src/CachedObjects/Struct/CacheColor.cs +++ b/src/CachedObjects/Struct/CacheColor.cs @@ -56,44 +56,44 @@ namespace Explorer if (CanWrite && IsExpanded) { - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); var whitespace = CalcWhitespace(window); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) }); r = GUILayout.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) }); g = GUILayout.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) }); b = GUILayout.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) }); a = GUILayout.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); // draw set value button - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); } } diff --git a/src/CachedObjects/Struct/CacheQuaternion.cs b/src/CachedObjects/Struct/CacheQuaternion.cs index 373d56b..19b12b8 100644 --- a/src/CachedObjects/Struct/CacheQuaternion.cs +++ b/src/CachedObjects/Struct/CacheQuaternion.cs @@ -51,38 +51,38 @@ namespace Explorer if (CanWrite && IsExpanded) { - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); var whitespace = CalcWhitespace(window); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); // draw set value button - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); } } diff --git a/src/CachedObjects/Struct/CacheRect.cs b/src/CachedObjects/Struct/CacheRect.cs index 5d3ed22..fb81641 100644 --- a/src/CachedObjects/Struct/CacheRect.cs +++ b/src/CachedObjects/Struct/CacheRect.cs @@ -53,44 +53,44 @@ namespace Explorer if (CanWrite && IsExpanded) { - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); var whitespace = CalcWhitespace(window); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("H:", new GUILayoutOption[] { GUILayout.Width(30) }); h = GUILayout.TextField(h, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); // draw set value button - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); } } diff --git a/src/CachedObjects/Struct/CacheVector.cs b/src/CachedObjects/Struct/CacheVector.cs index 8b0087a..db36a5b 100644 --- a/src/CachedObjects/Struct/CacheVector.cs +++ b/src/CachedObjects/Struct/CacheVector.cs @@ -88,52 +88,52 @@ namespace Explorer if (CanWrite && IsExpanded) { - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); var whitespace = CalcWhitespace(window); // always draw x and y - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); if (VectorSize > 2) { // draw z - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } if (VectorSize > 3) { // draw w - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } // draw set value button - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUIUnstrip.Space(whitespace); if (GUILayout.Button("Apply", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); } } diff --git a/src/Helpers/ReflectionHelpers.cs b/src/Helpers/ReflectionHelpers.cs index ba08773..60c952b 100644 --- a/src/Helpers/ReflectionHelpers.cs +++ b/src/Helpers/ReflectionHelpers.cs @@ -36,6 +36,9 @@ namespace Explorer public static bool IsEnumerable(Type t) { + // Not needed for Il2Cpp at the moment. Don't want these to behave as Enumerables. + //if (typeof(Transform).IsAssignableFrom(t)) return false; + return typeof(IEnumerable).IsAssignableFrom(t); } diff --git a/src/Helpers/UIHelpers.cs b/src/Helpers/UIHelpers.cs index d5fcca9..552f2ed 100644 --- a/src/Helpers/UIHelpers.cs +++ b/src/Helpers/UIHelpers.cs @@ -68,7 +68,7 @@ namespace Explorer // ------ toggle active button ------ - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUI.skin.button.alignment = TextAnchor.UpperLeft; GUI.color = activeColor; @@ -103,7 +103,7 @@ namespace Explorer SmallInspectButton(_obj); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } public static void SmallInspectButton(object obj) diff --git a/src/Menu/MainMenu/MainMenu.cs b/src/Menu/MainMenu/MainMenu.cs index f57865e..3750529 100644 --- a/src/Menu/MainMenu/MainMenu.cs +++ b/src/Menu/MainMenu/MainMenu.cs @@ -83,7 +83,7 @@ namespace Explorer private void MainHeader() { - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); for (int i = 0; i < Pages.Count; i++) { if (m_currentPage == i) @@ -96,9 +96,9 @@ namespace Explorer m_currentPage = i; } } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUI.color = Color.white; InspectUnderMouse.EnableInspect = GUILayout.Toggle(InspectUnderMouse.EnableInspect, "Inspect Under Mouse (Shift + RMB)", null); @@ -107,7 +107,7 @@ namespace Explorer if (setMouse != mouseState) CursorControl.ForceUnlockMouse = setMouse; WindowManager.TabView = GUILayout.Toggle(WindowManager.TabView, "Tab View", null); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); //GUIUnstrip.Space(10); GUIUnstrip.Space(10); diff --git a/src/Menu/MainMenu/Pages/ConsolePage.cs b/src/Menu/MainMenu/Pages/ConsolePage.cs index d07b4d8..d3448c2 100644 --- a/src/Menu/MainMenu/Pages/ConsolePage.cs +++ b/src/Menu/MainMenu/Pages/ConsolePage.cs @@ -159,7 +159,7 @@ MelonLogger.Log(""hello world"");"; GUILayout.Label("Using directives:", null); - GUILayout.BeginHorizontal(null); + 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) })) @@ -170,7 +170,7 @@ MelonLogger.Log(""hello world"");"; { ResetConsole(); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); foreach (var asm in UsingDirectives) { diff --git a/src/Menu/MainMenu/Pages/ScenePage.cs b/src/Menu/MainMenu/Pages/ScenePage.cs index bcdd7c3..a871103 100644 --- a/src/Menu/MainMenu/Pages/ScenePage.cs +++ b/src/Menu/MainMenu/Pages/ScenePage.cs @@ -200,7 +200,7 @@ namespace Explorer { DrawHeaderArea(); - GUILayout.BeginVertical(GUI.skin.box, null); + GUIUnstrip.BeginVertical(GUI.skin.box, null); DrawPageButtons(); @@ -213,7 +213,7 @@ namespace Explorer DrawSearchResultsList(); } - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); } catch { @@ -223,17 +223,17 @@ namespace Explorer private void DrawHeaderArea() { - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); // Current Scene label GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) }); SceneChangeButtons(); GUILayout.Label("" + m_currentScene + "", null); //new GUILayoutOption[] { GUILayout.Width(250) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); // ----- GameObject Search ----- - GUILayout.BeginHorizontal(GUI.skin.box, null); + GUIUnstrip.BeginHorizontal(GUI.skin.box, null); GUILayout.Label("Search Scene:", new GUILayoutOption[] { GUILayout.Width(100) }); m_searchInput = GUILayout.TextField(m_searchInput, null); @@ -242,7 +242,7 @@ namespace Explorer { Search(); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); GUIUnstrip.Space(5); } @@ -282,7 +282,7 @@ namespace Explorer private void DrawPageButtons() { - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); Pages.DrawLimitInputArea(); @@ -305,7 +305,7 @@ namespace Explorer } } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); GUI.skin.label.alignment = TextAnchor.UpperLeft; } @@ -313,7 +313,7 @@ namespace Explorer { if (m_currentTransform != null) { - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); if (GUILayout.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) })) { TraverseUp(); @@ -326,7 +326,7 @@ namespace Explorer UIHelpers.SmallInspectButton(m_currentTransform); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } else { diff --git a/src/Menu/MainMenu/Pages/SearchPage.cs b/src/Menu/MainMenu/Pages/SearchPage.cs index e982dce..d18542c 100644 --- a/src/Menu/MainMenu/Pages/SearchPage.cs +++ b/src/Menu/MainMenu/Pages/SearchPage.cs @@ -84,20 +84,20 @@ namespace Explorer try { // helpers - GUILayout.BeginHorizontal(GUI.skin.box, null); + 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) })) { //m_searchResults = GetInstanceClassScanner().ToList(); CacheResults(GetInstanceClassScanner()); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); // search box SearchBox(); // results - GUILayout.BeginVertical(GUI.skin.box, null); + GUIUnstrip.BeginVertical(GUI.skin.box, null); GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUILayout.Label("Results " + " (" + m_searchResults.Count + ")", null); @@ -105,7 +105,7 @@ namespace Explorer int count = m_searchResults.Count; - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); Pages.DrawLimitInputArea(); @@ -129,7 +129,7 @@ namespace Explorer } } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); resultsScroll = GUIUnstrip.BeginScrollView(resultsScroll); @@ -150,7 +150,7 @@ namespace Explorer } GUIUnstrip.EndScrollView(); - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); } catch { @@ -160,52 +160,52 @@ namespace Explorer private void SearchBox() { - GUILayout.BeginVertical(GUI.skin.box, null); + GUIUnstrip.BeginVertical(GUI.skin.box, null); // ----- GameObject Search ----- GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUILayout.Label("Search", null); GUI.skin.label.alignment = TextAnchor.UpperLeft; - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Name Contains:", new GUILayoutOption[] { GUILayout.Width(100) }); m_searchInput = GUILayout.TextField(m_searchInput, new GUILayoutOption[] { GUILayout.Width(200) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Class Filter:", new GUILayoutOption[] { GUILayout.Width(100) }); ClassFilterToggle(TypeFilter.Object, "Object"); ClassFilterToggle(TypeFilter.GameObject, "GameObject"); ClassFilterToggle(TypeFilter.Component, "Component"); ClassFilterToggle(TypeFilter.Custom, "Custom"); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); if (TypeMode == TypeFilter.Custom) { - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUI.skin.label.alignment = TextAnchor.MiddleRight; GUILayout.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) }); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.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); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); if (GUILayout.Button("Search", null)) { Search(); } - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); } private void ClassFilterToggle(TypeFilter mode, string label) diff --git a/src/Menu/Windows/GameObjectWindow.cs b/src/Menu/Windows/GameObjectWindow.cs index 3d5bc7f..9f7216d 100644 --- a/src/Menu/Windows/GameObjectWindow.cs +++ b/src/Menu/Windows/GameObjectWindow.cs @@ -217,7 +217,7 @@ namespace Explorer scroll = GUIUnstrip.BeginScrollView(scroll); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Scene: " + (m_scene == "" ? "n/a" : m_scene) + "", null); if (m_scene == UnityHelpers.ActiveSceneName) { @@ -231,9 +231,9 @@ namespace Explorer { WindowManager.InspectObject(Target, out _, true); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Path:", new GUILayoutOption[] { GUILayout.Width(50) }); string pathlabel = TargetGO.transform.GetGameObjectPath(); if (TargetGO.transform.parent != null) @@ -244,25 +244,25 @@ namespace Explorer } } GUILayout.TextArea(pathlabel, null); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Name:", new GUILayoutOption[] { GUILayout.Width(50) }); GUILayout.TextArea(m_name, null); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); // --- Horizontal Columns section --- - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); - GUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.Width(rect.width / 2 - 17) }); + GUIUnstrip.BeginVertical(new GUILayoutOption[] { GUILayout.Width(rect.width / 2 - 17) }); TransformList(rect); - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); - GUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.Width(rect.width / 2 - 17) }); + GUIUnstrip.BeginVertical(new GUILayoutOption[] { GUILayout.Width(rect.width / 2 - 17) }); ComponentList(rect); - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); - GUILayout.EndHorizontal(); // end horiz columns + GUIUnstrip.EndHorizontal(); // end horiz columns GameObjectControls(); @@ -283,20 +283,20 @@ namespace Explorer private void TransformList(Rect m_rect) { - GUILayout.BeginVertical(GUI.skin.box, null); + GUIUnstrip.BeginVertical(GUI.skin.box, null); m_transformScroll = GUIUnstrip.BeginScrollView(m_transformScroll); GUILayout.Label("Children", null); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); ChildPages.DrawLimitInputArea(); if (ChildPages.ItemCount > ChildPages.ItemsPerPage) { ChildPages.CurrentPageLabel(); - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) { @@ -307,7 +307,7 @@ namespace Explorer ChildPages.TurnPage(Turn.Right, ref this.m_transformScroll); } } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); if (m_children != null && m_children.Length > 0) { @@ -332,24 +332,24 @@ namespace Explorer } GUIUnstrip.EndScrollView(); - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); } private void ComponentList(Rect m_rect) { - GUILayout.BeginVertical(GUI.skin.box, null); + GUIUnstrip.BeginVertical(GUI.skin.box, null); m_compScroll = GUIUnstrip.BeginScrollView(m_compScroll); GUILayout.Label("Components", null); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); CompPages.DrawLimitInputArea(); if (CompPages.ItemCount > CompPages.ItemsPerPage) { CompPages.CurrentPageLabel(); - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) })) { @@ -360,9 +360,9 @@ namespace Explorer CompPages.TurnPage(Turn.Right, ref this.m_compScroll); } } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); m_addComponentInput = GUILayout.TextField(m_addComponentInput, new GUILayoutOption[] { GUILayout.Width(130) }); if (GUILayout.Button("Add Comp", null)) { @@ -382,7 +382,7 @@ namespace Explorer MelonLogger.LogWarning($"Could not find a type by the name of '{m_addComponentInput}'!"); } } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); GUI.skin.button.alignment = TextAnchor.MiddleLeft; if (m_cachedDestroyList.Count > 0) @@ -402,7 +402,7 @@ namespace Explorer var ilType = component.GetIl2CppType(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); if (ReflectionHelpers.BehaviourType.IsAssignableFrom(ilType)) { BehaviourEnabledBtn(component.TryCast()); @@ -419,7 +419,7 @@ namespace Explorer { m_cachedDestroyList.Add(component); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } } @@ -435,7 +435,7 @@ namespace Explorer GUIUnstrip.EndScrollView(); - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); } private void BehaviourEnabledBtn(Behaviour obj) @@ -465,28 +465,28 @@ namespace Explorer { if (m_hideControls) { - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("GameObject Controls", new GUILayoutOption[] { GUILayout.Width(200) }); if (GUILayout.Button("^ Show ^", new GUILayoutOption[] { GUILayout.Width(75) })) { m_hideControls = false; } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); return; } - GUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[] { GUILayout.Width(520) }); + GUIUnstrip.BeginVertical(GUI.skin.box, new GUILayoutOption[] { GUILayout.Width(520) }); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("GameObject Controls", new GUILayoutOption[] { GUILayout.Width(200) }); if (GUILayout.Button("v Hide v", new GUILayoutOption[] { GUILayout.Width(75) })) { m_hideControls = true; } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); bool m_active = TargetGO.activeSelf; m_active = GUILayout.Toggle(m_active, (m_active ? "Enabled " : "Disabled") + "", new GUILayoutOption[] { GUILayout.Width(80) }); @@ -510,8 +510,8 @@ namespace Explorer } } - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); m_setParentInput = GUILayout.TextField(m_setParentInput, null); if (GUILayout.Button("Set Parent", new GUILayoutOption[] { GUILayout.Width(80) })) @@ -530,15 +530,15 @@ namespace Explorer { TargetGO.transform.parent = null; } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginVertical(GUI.skin.box, null); + GUIUnstrip.BeginVertical(GUI.skin.box, null); m_cachedInput[0] = TranslateControl(TranslateType.Position, ref m_translateAmount, false); m_cachedInput[1] = TranslateControl(TranslateType.Rotation, ref m_rotateAmount, true); m_cachedInput[2] = TranslateControl(TranslateType.Scale, ref m_scaleAmount, false); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); if (GUILayout.Button("Apply to Transform", null) || m_autoApplyTransform) { if (m_localContext) @@ -562,12 +562,12 @@ namespace Explorer { CacheTransformValues(); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); BoolToggle(ref m_autoApplyTransform, "Auto-apply to Transform?"); BoolToggle(ref m_autoUpdateTransform, "Auto-update from transform?"); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); bool b = m_localContext; b = GUILayout.Toggle(b, "Use local transform values?", null); @@ -581,7 +581,7 @@ namespace Explorer } } - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); if (GUILayout.Button("Destroy", new GUILayoutOption[] { GUILayout.Width(120) })) { @@ -590,7 +590,7 @@ namespace Explorer return; } - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); } private void UpdateFreeze() @@ -626,7 +626,7 @@ namespace Explorer private Vector3 TranslateControl(TranslateType mode, ref float amount, bool multByTime) { - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label($"{(m_localContext ? "Local " : "")}{mode}:", new GUILayoutOption[] { GUILayout.Width(m_localContext ? 110 : 65) }); @@ -645,11 +645,11 @@ namespace Explorer GUILayout.Label(transform.localScale.ToString(), new GUILayoutOption[] { GUILayout.Width(250) }); break; } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); Vector3 input = m_cachedInput[(int)mode]; - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUI.skin.label.alignment = TextAnchor.MiddleRight; GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(20) }); @@ -670,7 +670,7 @@ namespace Explorer } GUI.skin.label.alignment = TextAnchor.UpperLeft; - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); return input; } diff --git a/src/Menu/Windows/ReflectionWindow.cs b/src/Menu/Windows/ReflectionWindow.cs index 6288a48..c8b7a17 100644 --- a/src/Menu/Windows/ReflectionWindow.cs +++ b/src/Menu/Windows/ReflectionWindow.cs @@ -235,17 +235,17 @@ namespace Explorer GUIUnstrip.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box); } - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Type: " + TargetType.FullName + "", new GUILayoutOption[] { GUILayout.Width(245f) }); if (m_uObj) { GUILayout.Label("Name: " + m_uObj.name, null); } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); if (m_uObj) { - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Tools:", new GUILayoutOption[] { GUILayout.Width(80) }); UIHelpers.InstantiateButton(m_uObj); if (m_component && m_component.gameObject is GameObject obj) @@ -261,25 +261,25 @@ namespace Explorer } GUI.skin.label.alignment = TextAnchor.UpperLeft; } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } UIStyles.HorizontalLine(Color.grey); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Search:", new GUILayoutOption[] { GUILayout.Width(75) }); m_search = GUILayout.TextField(m_search, null); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Filter:", new GUILayoutOption[] { GUILayout.Width(75) }); FilterToggle(MemberTypes.All, "All"); FilterToggle(MemberTypes.Property, "Properties"); FilterToggle(MemberTypes.Field, "Fields"); FilterToggle(MemberTypes.Method, "Methods"); - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); GUILayout.Label("Values:", new GUILayoutOption[] { GUILayout.Width(75) }); if (GUILayout.Button("Update", new GUILayoutOption[] { GUILayout.Width(100) })) { @@ -290,14 +290,14 @@ namespace Explorer GUI.color = m_hideFailedReflection ? Color.green : Color.red; m_hideFailedReflection = GUILayout.Toggle(m_hideFailedReflection, "Hide failed Reflection?", new GUILayoutOption[] { GUILayout.Width(150) }); GUI.color = Color.white; - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); GUIUnstrip.Space(10); Pages.ItemCount = m_cachedMembersFiltered.Length; // prev/next page buttons - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginHorizontal(); Pages.DrawLimitInputArea(); @@ -315,7 +315,7 @@ namespace Explorer Pages.TurnPage(Turn.Right, ref this.scroll); } } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); // ====== BODY ====== @@ -325,7 +325,7 @@ namespace Explorer UIStyles.HorizontalLine(Color.grey); - GUILayout.BeginVertical(GUI.skin.box, null); + GUIUnstrip.BeginVertical(GUI.skin.box, null); var members = this.m_cachedMembersFiltered; int start = Pages.CalculateOffsetIndex(); @@ -334,24 +334,24 @@ namespace Explorer { var holder = members[j]; - GUILayout.BeginHorizontal(new GUILayoutOption[] { GUILayout.Height(25) }); + GUIUnstrip.BeginHorizontal(new GUILayoutOption[] { GUILayout.Height(25) }); try { holder.Draw(rect, 180f); } catch { - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); continue; } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); // if not last element if (!(j == (start + Pages.ItemsPerPage - 1) || j == (members.Length - 1))) UIStyles.HorizontalLine(new Color(0.07f, 0.07f, 0.07f), true); } - GUILayout.EndVertical(); + GUIUnstrip.EndVertical(); GUIUnstrip.EndScrollView(); if (!WindowManager.TabView) diff --git a/src/Menu/Windows/ResizeDrag.cs b/src/Menu/Windows/ResizeDrag.cs index d263be0..5265265 100644 --- a/src/Menu/Windows/ResizeDrag.cs +++ b/src/Menu/Windows/ResizeDrag.cs @@ -26,7 +26,7 @@ namespace Explorer try { - GUILayout.BeginHorizontal(GUI.skin.box, null); + GUIUnstrip.BeginHorizontal(GUI.skin.box, null); GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) }); @@ -57,7 +57,7 @@ namespace Explorer _rect.yMax = Mathf.Min(Screen.height, _rect.yMax); // modifying yMax affects height, not y } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); } catch (Il2CppException e) when (e.Message.StartsWith("System.ArgumentException")) { @@ -76,7 +76,7 @@ namespace Explorer } else { - GUILayout.BeginHorizontal(GUI.skin.box, null); + GUIUnstrip.BeginHorizontal(GUI.skin.box, null); GUILayout.Label("Resize window:", new GUILayoutOption[] { GUILayout.Width(100) }); @@ -100,7 +100,7 @@ namespace Explorer _rect.height += 5f; } - GUILayout.EndHorizontal(); + GUIUnstrip.EndHorizontal(); GUI.skin.label.alignment = TextAnchor.UpperLeft; } diff --git a/src/Menu/Windows/TabViewWindow.cs b/src/Menu/Windows/TabViewWindow.cs index 3213172..bd798d1 100644 --- a/src/Menu/Windows/TabViewWindow.cs +++ b/src/Menu/Windows/TabViewWindow.cs @@ -67,8 +67,8 @@ namespace Explorer GUIUnstrip.BeginArea(new Rect(5, 25, m_rect.width - 10, m_rect.height - 35), GUI.skin.box); - GUILayout.BeginVertical(GUI.skin.box, null); - GUILayout.BeginHorizontal(null); + GUIUnstrip.BeginVertical(GUI.skin.box, null); + GUIUnstrip.BeginHorizontal(); GUI.skin.button.alignment = TextAnchor.MiddleLeft; int tabPerRow = Mathf.FloorToInt((float)((decimal)m_rect.width / 238)); int rowCount = 0; @@ -77,8 +77,8 @@ namespace Explorer if (rowCount >= tabPerRow) { rowCount = 0; - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(null); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.BeginHorizontal(); } rowCount++; @@ -97,8 +97,8 @@ namespace Explorer } } GUI.color = Color.white; - GUILayout.EndHorizontal(); - GUILayout.EndVertical(); + GUIUnstrip.EndHorizontal(); + GUIUnstrip.EndVertical(); GUI.skin.button.alignment = TextAnchor.MiddleCenter; m_targetWindow.WindowFunction(m_targetWindow.windowID); diff --git a/src/UnstripFixes/GUIUnstrip.cs b/src/UnstripFixes/GUIUnstrip.cs index b8d3b97..1c8baf2 100644 --- a/src/UnstripFixes/GUIUnstrip.cs +++ b/src/UnstripFixes/GUIUnstrip.cs @@ -52,6 +52,8 @@ namespace Explorer return m_scrollStack; } + // ================= Fix for Space ================= + public static void Space(float pixels) { GUIUtility.CheckOnGUI(); @@ -67,7 +69,7 @@ namespace Explorer } } - // Fix for BeginArea + // ================= Fix for BeginArea ================= static public void BeginArea(Rect screenRect) { BeginArea(screenRect, GUIContent.none, GUIStyle.none); } static public void BeginArea(Rect screenRect, string text) { BeginArea(screenRect, GUIContent.Temp(text), GUIStyle.none); } @@ -77,7 +79,6 @@ namespace Explorer static public void BeginArea(Rect screenRect, string text, GUIStyle style) { BeginArea(screenRect, GUIContent.Temp(text), style); } static public void BeginArea(Rect screenRect, Texture image, GUIStyle style) { BeginArea(screenRect, GUIContent.Temp(image), style); } - // Begin a GUILayout block of GUI controls in a fixed screen area. static public void BeginArea(Rect screenRect, GUIContent content, GUIStyle style) { GUILayoutGroup g = GUILayoutUtility.BeginLayoutArea(style, Il2CppType.Of()); @@ -92,7 +93,6 @@ namespace Explorer GUI.BeginGroup(g.rect, content, style); } - // Close a GUILayout block started with BeginArea static public void EndArea() { if (Event.current.type == EventType.Used) @@ -102,7 +102,7 @@ namespace Explorer GUI.EndGroup(); } - // Fix for BeginGroup + // ================= Fix for BeginGroup ================= public static void BeginGroup(Rect position) { BeginGroup(position, GUIContent.none, GUIStyle.none); } public static void BeginGroup(Rect position, string text) { BeginGroup(position, GUIContent.Temp(text), GUIStyle.none); } @@ -139,7 +139,130 @@ namespace Explorer GUIClip.Internal_Pop(); } - // Fix for BeginScrollView. + // ================= Fix for BeginVertical ================= + + public static void BeginVertical(params GUILayoutOption[] options) { BeginVertical(GUIContent.none, GUIStyle.none, options); } + public static void BeginVertical(GUIStyle style, params GUILayoutOption[] options) { BeginVertical(GUIContent.none, style, options); } + public static void BeginVertical(string text, GUIStyle style, params GUILayoutOption[] options) { BeginVertical(GUIContent.Temp(text), style, options); } + public static void BeginVertical(Texture image, GUIStyle style, params GUILayoutOption[] options) { BeginVertical(GUIContent.Temp(image), style, options); } + + public static void BeginVertical(GUIContent content, GUIStyle style, params GUILayoutOption[] options) + { + var g = GUILayoutUtility.BeginLayoutGroup(style, options, Il2CppType.Of()); + g.isVertical = true; + if (style != GUIStyle.none || content != GUIContent.none) + GUI.Box(g.rect, content, style); + } + + public static void EndVertical() + { + GUILayoutUtility.EndLayoutGroup(); + } + + // ================= Fix for BeginHorizontal ================== + + public static void BeginHorizontal(params GUILayoutOption[] options) { BeginHorizontal(GUIContent.none, GUIStyle.none, options); } + public static void BeginHorizontal(GUIStyle style, params GUILayoutOption[] options) { BeginHorizontal(GUIContent.none, style, options); } + public static void BeginHorizontal(string text, GUIStyle style, params GUILayoutOption[] options) { BeginHorizontal(GUIContent.Temp(text), style, options); } + + public static void BeginHorizontal(Texture image, GUIStyle style, params GUILayoutOption[] options) + { BeginHorizontal(GUIContent.Temp(image), style, options); } + public static void BeginHorizontal(GUIContent content, GUIStyle style, params GUILayoutOption[] options) + { + GUILayoutGroup g = GUILayoutUtility.BeginLayoutGroup(style, options, Il2CppType.Of()); + g.isVertical = false; + if (style != GUIStyle.none || content != GUIContent.none) + GUI.Box(g.rect, content, style); + } + + public static void EndHorizontal() + { + GUILayoutUtility.EndLayoutGroup(); + } + + // =========== Fix for GUI elements ============= + + static public void Label(Texture image, params GUILayoutOption[] options) { DoLabel(GUIContent.Temp(image), GUI.skin.label, options); } + static public void Label(string text, params GUILayoutOption[] options) { DoLabel(GUIContent.Temp(text), GUI.skin.label, options); } + static public void Label(GUIContent content, params GUILayoutOption[] options) { DoLabel(content, GUI.skin.label, options); } + static public void Label(Texture image, GUIStyle style, params GUILayoutOption[] options) { DoLabel(GUIContent.Temp(image), style, options); } + static public void Label(string text, GUIStyle style, params GUILayoutOption[] options) { DoLabel(GUIContent.Temp(text), style, options); } + // Make an auto-layout label. + static public void Label(GUIContent content, GUIStyle style, params GUILayoutOption[] options) { DoLabel(content, style, options); } + static void DoLabel(GUIContent content, GUIStyle style, GUILayoutOption[] options) + { GUI.Label(LayoutUtilityUnstrip.GetRect(content, style, options), content, style); } + + static public void Box(Texture image, params GUILayoutOption[] options) { DoBox(GUIContent.Temp(image), GUI.skin.box, options); } + static public void Box(string text, params GUILayoutOption[] options) { DoBox(GUIContent.Temp(text), GUI.skin.box, options); } + static public void Box(GUIContent content, params GUILayoutOption[] options) { DoBox(content, GUI.skin.box, options); } + static public void Box(Texture image, GUIStyle style, params GUILayoutOption[] options) { DoBox(GUIContent.Temp(image), style, options); } + static public void Box(string text, GUIStyle style, params GUILayoutOption[] options) { DoBox(GUIContent.Temp(text), style, options); } + // Make an auto-layout box. + static public void Box(GUIContent content, GUIStyle style, params GUILayoutOption[] options) { DoBox(content, style, options); } + static void DoBox(GUIContent content, GUIStyle style, GUILayoutOption[] options) + { GUI.Box(LayoutUtilityUnstrip.GetRect(content, style, options), content, style); } + + static public bool Button(Texture image, params GUILayoutOption[] options) { return DoButton(GUIContent.Temp(image), GUI.skin.button, options); } + static public bool Button(string text, params GUILayoutOption[] options) { return DoButton(GUIContent.Temp(text), GUI.skin.button, options); } + static public bool Button(GUIContent content, params GUILayoutOption[] options) { return DoButton(content, GUI.skin.button, options); } + static public bool Button(Texture image, GUIStyle style, params GUILayoutOption[] options) { return DoButton(GUIContent.Temp(image), style, options); } + static public bool Button(string text, GUIStyle style, params GUILayoutOption[] options) { return DoButton(GUIContent.Temp(text), style, options); } + // Make a single press button. The user clicks them and something happens immediately. + static public bool Button(GUIContent content, GUIStyle style, params GUILayoutOption[] options) { return DoButton(content, style, options); } + static bool DoButton(GUIContent content, GUIStyle style, GUILayoutOption[] options) + { return GUI.Button(LayoutUtilityUnstrip.GetRect(content, style, options), content, style); } + + static public bool RepeatButton(Texture image, params GUILayoutOption[] options) { return DoRepeatButton(GUIContent.Temp(image), GUI.skin.button, options); } + static public bool RepeatButton(string text, params GUILayoutOption[] options) { return DoRepeatButton(GUIContent.Temp(text), GUI.skin.button, options); } + static public bool RepeatButton(GUIContent content, params GUILayoutOption[] options) { return DoRepeatButton(content, GUI.skin.button, options); } + static public bool RepeatButton(Texture image, GUIStyle style, params GUILayoutOption[] options) { return DoRepeatButton(GUIContent.Temp(image), style, options); } + static public bool RepeatButton(string text, GUIStyle style, params GUILayoutOption[] options) { return DoRepeatButton(GUIContent.Temp(text), style, options); } + // 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); } + + 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); } + public static string TextField(string text, GUIStyle style, params GUILayoutOption[] options) { return DoTextField(text, -1, false, style, options); } + // Make a single-line text field where the user can edit a string. + public static string TextField(string text, int maxLength, GUIStyle style, params GUILayoutOption[] options) { return DoTextField(text, maxLength, false, style, options); } + + public static string TextArea(string text, params GUILayoutOption[] options) { return DoTextField(text, -1, true, GUI.skin.textArea, options); } + public static string TextArea(string text, int maxLength, params GUILayoutOption[] options) { return DoTextField(text, maxLength, true, GUI.skin.textArea, options); } + public static string TextArea(string text, GUIStyle style, params GUILayoutOption[] options) { return DoTextField(text, -1, true, style, options); } + // Make a multi-line text field where the user can edit a string. + public static string TextArea(string text, int maxLength, GUIStyle style, params GUILayoutOption[] options) { return DoTextField(text, maxLength, true, style, options); } + + static string DoTextField(string text, int maxLength, bool multiline, GUIStyle style, GUILayoutOption[] options) + { + int id = GUIUtility.GetControlID(FocusType.Keyboard); + GUIContent content; + Rect r; + if (GUIUtility.keyboardControl != id) + content = GUIContent.Temp(text); + else + content = GUIContent.Temp(text + GUIUtility.compositionString); + + r = LayoutUtilityUnstrip.GetRect(content, style, options); + if (GUIUtility.keyboardControl == id) + content = GUIContent.Temp(text); + GUI.DoTextField(r, id, content, multiline, maxLength, style); + return content.text; + } + + static public bool Toggle(bool value, Texture image, params GUILayoutOption[] options) { return DoToggle(value, GUIContent.Temp(image), GUI.skin.toggle, options); } + static public bool Toggle(bool value, string text, params GUILayoutOption[] options) { return DoToggle(value, GUIContent.Temp(text), GUI.skin.toggle, options); } + static public bool Toggle(bool value, GUIContent content, params GUILayoutOption[] options) { return DoToggle(value, content, GUI.skin.toggle, options); } + static public bool Toggle(bool value, Texture image, GUIStyle style, params GUILayoutOption[] options) { return DoToggle(value, GUIContent.Temp(image), style, options); } + static public bool Toggle(bool value, string text, GUIStyle style, params GUILayoutOption[] options) { return DoToggle(value, GUIContent.Temp(text), style, options); } + // Make an on/off toggle button. + static public bool Toggle(bool value, GUIContent content, GUIStyle style, params GUILayoutOption[] options) { return DoToggle(value, content, style, options); } + + static bool DoToggle(bool value, GUIContent content, GUIStyle style, GUILayoutOption[] options) + { return GUI.Toggle(LayoutUtilityUnstrip.GetRect(content, style, options), value, content, style); } + + // ================= Fix for BeginScrollView. ======================= public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options) {