Skip to content

Commit 37e90ee

Browse files
committed
Use shims added in #115
1 parent f0272ce commit 37e90ee

File tree

10 files changed

+25
-26
lines changed

10 files changed

+25
-26
lines changed

RuntimeUnityEditor.Bepin5/PatchInspector/PatchInspector.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected override void DrawContents()
101101
if (foundPatches.Count > 0)
102102
{
103103
GUILayout.Label($"Found {foundPatches.Count} patches:");
104-
scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(true));
104+
scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayoutShim.ExpandHeight(true));
105105

106106
foreach (var patch in foundPatches)
107107
{
@@ -549,7 +549,7 @@ private void DrawILViewerWindow(int windowId, ILViewerWindow window)
549549
private void DrawOriginalMethodView(ILViewerWindow window)
550550
{
551551
GUILayout.Label("Original Method IL Code:");
552-
window.ScrollPosition = GUILayout.BeginScrollView(window.ScrollPosition, GUILayout.ExpandHeight(true));
552+
window.ScrollPosition = GUILayout.BeginScrollView(window.ScrollPosition, GUILayoutShim.ExpandHeight(true));
553553
GUILayout.TextArea(window.OriginalIL);
554554
GUILayout.EndScrollView();
555555
}
@@ -569,7 +569,7 @@ private void DrawPatchManagerView(ILViewerWindow window)
569569
if (GUILayout.Button("Refresh Patch List", GUILayout.Height(25)))
570570
RefreshPatchList(window);
571571

572-
window.PatchListScrollPosition = GUILayout.BeginScrollView(window.PatchListScrollPosition, GUILayout.ExpandHeight(true));
572+
window.PatchListScrollPosition = GUILayout.BeginScrollView(window.PatchListScrollPosition, GUILayoutShim.ExpandHeight(true));
573573

574574
for (var i = 0; i < window.PatchMethods.Count; i++)
575575
{
@@ -615,7 +615,7 @@ private void DrawPatchManagerView(ILViewerWindow window)
615615
var selectedPatch = window.PatchMethods[window.SelectedPatchIndex];
616616
GUILayout.Label($"IL Code for: {selectedPatch.PatchType} - {selectedPatch.PatchMethod.DeclaringType?.Name}.{selectedPatch.PatchMethod.Name}", GUI.skin.label);
617617

618-
window.ScrollPosition = GUILayout.BeginScrollView(window.ScrollPosition, GUILayout.ExpandHeight(true));
618+
window.ScrollPosition = GUILayout.BeginScrollView(window.ScrollPosition, GUILayoutShim.ExpandHeight(true));
619619

620620
GUILayout.TextArea(selectedPatch.ILCode);
621621

RuntimeUnityEditor.Core/Features/ContextMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ protected override void OnGUI()
374374

375375
private void DisableOnClickWindowFunc(int id)
376376
{
377-
if (GUILayout.Button(GUIContent.none, GUI.skin.label, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) Enabled = false;
377+
if (GUILayout.Button(GUIContent.none, GUI.skin.label, GUILayoutShim.ExpandWidth(true), GUILayoutShim.ExpandHeight(true))) Enabled = false;
378378
}
379379

380380
private void DrawMenu(int id)

RuntimeUnityEditor.Core/Utils/Abstractions/GUILayoutShim.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static GUILayoutOption MaxWidth(float width)
1414
#endif
1515
}
1616

17-
public static GUILayoutOption ExpandWidth(bool expand)
17+
public static GUILayoutOption ExpandWidth(bool expand)
1818
{
1919
#if IL2CPP
2020
var entity = new UnityEngine.GUILayoutOption(GUILayoutOption.Type.stretchWidth, expand);

RuntimeUnityEditor.Core/Utils/IMGUIUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public static class IMGUIUtils
1111
/// <summary>
1212
/// Options with GUILayout.ExpandWidth(true). Useful for avoiding allocations.
1313
/// </summary>
14-
public static readonly GUILayoutOption[] LayoutOptionsExpandWidthTrue = { GUILayout.ExpandWidth(true) };
14+
public static readonly GUILayoutOption[] LayoutOptionsExpandWidthTrue = { GUILayoutShim.ExpandWidth(true) };
1515

1616
/// <summary>
1717
/// Options with GUILayout.ExpandWidth(false). Useful for avoiding allocations.
1818
/// </summary>
19-
public static readonly GUILayoutOption[] LayoutOptionsExpandWidthFalse = { GUILayout.ExpandWidth(false) };
19+
public static readonly GUILayoutOption[] LayoutOptionsExpandWidthFalse = { GUILayoutShim.ExpandWidth(false) };
2020

2121
private static Texture2D SolidBoxTex { get; set; }
2222

RuntimeUnityEditor.Core/Windows/Clipboard/ClipboardWindow.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ protected override void DrawContents()
5656

5757
GUILayout.BeginHorizontal();
5858
{
59-
GUILayout.Label("Index", GUILayout.Width(widthIndex), GUILayout.ExpandWidth(false));
60-
GUILayout.Label("Type", GUILayout.Width(widthName), GUILayout.ExpandWidth(false));
59+
GUILayout.Label("Index", GUILayout.Width(widthIndex), GUILayoutShim.ExpandWidth(false));
60+
GUILayout.Label("Type", GUILayout.Width(widthName), GUILayoutShim.ExpandWidth(false));
6161
GUILayout.Label("Value", IMGUIUtils.LayoutOptionsExpandWidthTrue);
6262
}
6363
GUILayout.EndHorizontal();
@@ -70,12 +70,12 @@ protected override void DrawContents()
7070
{
7171
var content = Contents[index];
7272

73-
if (GUILayout.Button(index.ToString(), GUI.skin.label, GUILayout.Width(widthIndex), GUILayout.ExpandWidth(false)) && IMGUIUtils.IsMouseRightClick())
73+
if (GUILayout.Button(index.ToString(), GUI.skin.label, GUILayout.Width(widthIndex), GUILayoutShim.ExpandWidth(false)) && IMGUIUtils.IsMouseRightClick())
7474
ContextMenu.Instance.Show(content);
7575

7676
var type = content?.GetType();
7777

78-
if (GUILayout.Button(type?.Name ?? "NULL", GUI.skin.label, GUILayout.Width(widthName), GUILayout.ExpandWidth(false)) && IMGUIUtils.IsMouseRightClick())
78+
if (GUILayout.Button(type?.Name ?? "NULL", GUI.skin.label, GUILayout.Width(widthName), GUILayoutShim.ExpandWidth(false)) && IMGUIUtils.IsMouseRightClick())
7979
ContextMenu.Instance.Show(content);
8080

8181
var prevEnabled = GUI.enabled;

RuntimeUnityEditor.Core/Windows/Inspector/Inspector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ protected override void DrawContents()
257257
_tabScrollPos = GUILayout.BeginScrollView(_tabScrollPos, false, false,
258258
GUI.skin.horizontalScrollbar, GUIStyle.none, GUIStyle.none); //, GUILayout.Height(46)
259259
{
260-
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));
260+
GUILayout.BeginHorizontal(GUILayoutShim.ExpandWidth(false), GUILayoutShim.ExpandHeight(false));
261261
for (var index = 0; index < _tabs.Count; index++)
262262
{
263263
var tab = _tabs[index];
@@ -292,7 +292,7 @@ protected override void DrawContents()
292292
currentTab.InspectorStackScrollPos = GUILayout.BeginScrollView(currentTab.InspectorStackScrollPos, false, false,
293293
GUI.skin.horizontalScrollbar, GUIStyle.none, GUIStyle.none); //, GUILayout.Height(46)
294294
{
295-
GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false));
295+
GUILayout.BeginHorizontal(GUI.skin.box, GUILayoutShim.ExpandWidth(false), GUILayoutShim.ExpandHeight(false));
296296
var stackEntries = currentTab.InspectorStack.Reverse().ToArray();
297297
for (var i = 0; i < stackEntries.Length; i++)
298298
{

RuntimeUnityEditor.Core/Windows/Inspector/VariableFieldDrawer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ private static void DrawFlagsField(ICacheEntry setting, IList enumValues, object
155155
break;
156156

157157
GUI.changed = false;
158-
var newVal = GUILayout.Toggle((currentValue & value.val) == value.val, value.name,
159-
GUILayout.ExpandWidth(false));
158+
var newVal = GUILayout.Toggle((currentValue & value.val) == value.val, value.name, IMGUIUtils.LayoutOptionsExpandWidthFalse);
160159
if (GUI.changed)
161160
{
162161
var newValue = newVal ? currentValue | value.val : currentValue & ~value.val;

RuntimeUnityEditor.Core/Windows/ObjectTree/ObjectTreeViewer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private void DisplayObjectTreeHelper(GameObject go, int indent, ref int currentC
180180
GUILayout.Space(20f);
181181
}
182182

183-
if (GUILayout.Button(go.name, GUI.skin.label, GUILayout.ExpandWidth(true), GUILayoutShim.MinWidth(200), GUILayout.ExpandHeight(false)))
183+
if (GUILayout.Button(go.name, GUI.skin.label, GUILayoutShim.ExpandWidth(true), GUILayoutShim.MinWidth(200), GUILayoutShim.ExpandHeight(false)))
184184
{
185185
if (IMGUIUtils.IsMouseRightClick())
186186
{
@@ -336,7 +336,7 @@ private static void DrawVector3(string memberName, Transform transform, Action<T
336336
GUI.changed = false;
337337
GUILayout.BeginHorizontal();
338338
{
339-
GUILayout.Label(memberName, GUILayout.ExpandWidth(true), _drawVector3FieldHeight);
339+
GUILayout.Label(memberName, GUILayoutShim.ExpandWidth(true), _drawVector3FieldHeight);
340340
v3New.x = GUILayout.HorizontalSlider(v3.x, minVal, maxVal, _drawVector3SliderWidth, _drawVector3SliderHeight);
341341
float.TryParse(GUILayout.TextField(v3New.x.ToString("F2", CultureInfo.InvariantCulture), _drawVector3FieldWidth, _drawVector3FieldHeight), NumberStyles.Any, CultureInfo.InvariantCulture, out v3New.x);
342342
v3New.y = GUILayout.HorizontalSlider(v3.y, minVal, maxVal, _drawVector3SliderWidth, _drawVector3SliderHeight);
@@ -357,7 +357,7 @@ private static void DrawVector2(string memberName, Transform transform, Action<T
357357
GUI.changed = false;
358358
GUILayout.BeginHorizontal();
359359
{
360-
GUILayout.Label(memberName, GUILayout.ExpandWidth(true), _drawVector3FieldHeight);
360+
GUILayout.Label(memberName, GUILayoutShim.ExpandWidth(true), _drawVector3FieldHeight);
361361
vector2New.x = GUILayout.HorizontalSlider(vector2.x, minVal, maxVal, _drawVector3SliderWidth, _drawVector3SliderHeight);
362362
float.TryParse(GUILayout.TextField(vector2New.x.ToString("F2", CultureInfo.InvariantCulture), _drawVector3FieldWidth, _drawVector3FieldHeight), NumberStyles.Any, CultureInfo.InvariantCulture, out vector2New.x);
363363
vector2New.y = GUILayout.HorizontalSlider(vector2.y, minVal, maxVal, _drawVector3SliderWidth, _drawVector3SliderHeight);
@@ -555,7 +555,7 @@ private void DisplayObjectTree()
555555
DisplayTreeSearchBox();
556556

557557
_treeScrollPosition = GUILayout.BeginScrollView(_treeScrollPosition,
558-
GUILayout.Height(_objectTreeHeight), GUILayout.ExpandWidth(true));
558+
GUILayout.Height(_objectTreeHeight), GUILayoutShim.ExpandWidth(true));
559559
{
560560
var currentCount = 0;
561561
var notVisibleCount = 0;

RuntimeUnityEditor.Core/Windows/ObjectView/ObjectViewWindow.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public sealed class ObjectViewWindow : Window<ObjectViewWindow>
2020

2121
private static Dictionary<Type, Action<object>> _objectDrawers = new Dictionary<Type, Action<object>>
2222
{
23-
{typeof(Texture), o => GUILayout.Label((Texture)o, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))},
24-
{typeof(GUIContent), o => GUILayout.Label((GUIContent)o, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))},
25-
{typeof(string), o => GUILayout.TextArea((string)o, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))},
23+
{typeof(Texture), o => GUILayout.Label((Texture)o, GUILayoutShim.ExpandWidth(true), GUILayoutShim.ExpandHeight(true))},
24+
{typeof(GUIContent), o => GUILayout.Label((GUIContent)o, GUILayoutShim.ExpandWidth(true), GUILayoutShim.ExpandHeight(true))},
25+
{typeof(string), o => GUILayout.TextArea((string)o, GUILayoutShim.ExpandWidth(true), GUILayoutShim.ExpandHeight(true))},
2626
};
2727

2828
private static bool GetDrawer(object objToDisplay, out Action<object> drawer)
@@ -87,7 +87,7 @@ protected override void DrawContents()
8787
}
8888
GUILayout.EndHorizontal();
8989

90-
_scrollPos = GUILayout.BeginScrollView(_scrollPos, true, true, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
90+
_scrollPos = GUILayout.BeginScrollView(_scrollPos, true, true, GUILayoutShim.ExpandWidth(true), GUILayoutShim.ExpandHeight(true));
9191
{
9292
_objDrawer(_objToDisplay);
9393
}

RuntimeUnityEditor.Core/Windows/Taskbar.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ void IFeature.OnOnGUI()
6363
_windowRect,
6464
(GUI.WindowFunction)DrawTaskbar,
6565
GetTitle(),
66-
GUILayout.ExpandHeight(false),
67-
GUILayout.ExpandWidth(false),
66+
GUILayoutShim.ExpandHeight(false),
67+
GUILayoutShim.ExpandWidth(false),
6868
GUILayoutShim.MaxWidth(Screen.width)
6969
);
7070
IMGUIUtils.EatInputInRect(_windowRect);

0 commit comments

Comments
 (0)