Fix BeginVertical and BeginHorizontal

This commit is contained in:
sinaioutlander
2020-09-13 23:16:12 +10:00
parent 065ab033c9
commit 653b4a2304
18 changed files with 305 additions and 179 deletions

View File

@ -217,7 +217,7 @@ namespace Explorer
scroll = GUIUnstrip.BeginScrollView(scroll);
GUILayout.BeginHorizontal(null);
GUIUnstrip.BeginHorizontal();
GUILayout.Label("Scene: <color=cyan>" + (m_scene == "" ? "n/a" : m_scene) + "</color>", 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("<b><size=15>Children</size></b>", 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("<b><size=15>Components</size></b>", 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<Behaviour>());
@ -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("<b><size=15>GameObject Controls</size></b>", 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("<b><size=15>GameObject Controls</size></b>", 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 ? "<color=lime>Enabled " : "<color=red>Disabled") + "</color>",
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("<color=lime>Apply to Transform</color>", 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, "<color=" + (b ? "lime" : "red") + ">Use local transform values?</color>", null);
@ -581,7 +581,7 @@ namespace Explorer
}
}
GUILayout.EndVertical();
GUIUnstrip.EndVertical();
if (GUILayout.Button("<color=red><b>Destroy</b></color>", 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($"<color=cyan><b>{(m_localContext ? "Local " : "")}{mode}</b></color>:",
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("<color=cyan>X:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
@ -670,7 +670,7 @@ namespace Explorer
}
GUI.skin.label.alignment = TextAnchor.UpperLeft;
GUILayout.EndHorizontal();
GUIUnstrip.EndHorizontal();
return input;
}

View File

@ -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("<b>Type:</b> <color=cyan>" + TargetType.FullName + "</color>", 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("<b>Tools:</b>", 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("<b>Search:</b>", new GUILayoutOption[] { GUILayout.Width(75) });
m_search = GUILayout.TextField(m_search, null);
GUILayout.EndHorizontal();
GUIUnstrip.EndHorizontal();
GUILayout.BeginHorizontal(null);
GUIUnstrip.BeginHorizontal();
GUILayout.Label("<b>Filter:</b>", 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("<b>Values:</b>", 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)

View File

@ -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;
}

View File

@ -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);