Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 2d7dfa5

Browse files
committed
Fix scroll not working in 2017 games
1 parent eff8d63 commit 2d7dfa5

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

lib/mcs.NET35.dll

1.47 MB
Binary file not shown.

src/Menu/MainMenu/MainMenu.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System.Linq;
44
using System.Text;
55
using UnityEngine;
6-
using UnityEngine.UI;
7-
using UnityEngine.EventSystems;
86
using MelonLoader;
97

108
namespace Explorer

src/Menu/Windows/WindowManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using UnhollowerRuntimeLib;
99
using UnityEngine;
1010
using UnityEngine.Events;
11-
using UnityEngine.EventSystems;
1211

1312
namespace Explorer
1413
{

src/UnstripFixes/GUIUnstrip.cs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,36 @@ public class GUIUnstrip
2020
public static bool ScrollFailed = false;
2121
public static bool ManualUnstripFailed = false;
2222

23-
private static GenericStack ScrollStack
23+
private static GenericStack ScrollStack => m_scrollStack ?? GetScrollStack();
24+
private static PropertyInfo m_scrollViewStatesInfo;
25+
private static GenericStack m_scrollStack;
26+
27+
private static GenericStack GetScrollStack()
2428
{
25-
get
29+
if (m_scrollViewStatesInfo == null)
2630
{
27-
if (m_scrollViewStatesInfo == null)
31+
if (typeof(GUI).GetProperty("scrollViewStates", ReflectionHelpers.CommonFlags) is PropertyInfo scrollStatesInfo)
2832
{
29-
try
30-
{
31-
m_scrollViewStatesInfo = typeof(GUI).GetProperty("scrollViewStates");
32-
if (m_scrollViewStatesInfo == null) throw new Exception();
33-
}
34-
catch
35-
{
36-
m_scrollViewStatesInfo = typeof(GUI).GetProperty("s_scrollViewStates");
37-
}
33+
m_scrollViewStatesInfo = scrollStatesInfo;
34+
}
35+
else if (typeof(GUI).GetProperty("s_ScrollViewStates", ReflectionHelpers.CommonFlags) is PropertyInfo s_scrollStatesInfo)
36+
{
37+
m_scrollViewStatesInfo = s_scrollStatesInfo;
3838
}
39+
}
3940

40-
return (GenericStack)m_scrollViewStatesInfo?.GetValue(null, null);
41+
if (m_scrollViewStatesInfo?.GetValue(null, null) is GenericStack stack)
42+
{
43+
m_scrollStack = stack;
44+
}
45+
else
46+
{
47+
m_scrollStack = new GenericStack();
4148
}
49+
50+
return m_scrollStack;
4251
}
43-
private static PropertyInfo m_scrollViewStatesInfo;
44-
52+
4553
public static void Space(float pixels)
4654
{
4755
GUIUtility.CheckOnGUI();
@@ -145,7 +153,7 @@ private static Vector2 BeginScrollView_ImplLayout(Vector2 scrollPosition, bool a
145153
private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal,
146154
bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background)
147155
{
148-
GUIUtility.CheckOnGUI();
156+
// GUIUtility.CheckOnGUI();
149157

150158
int controlID = GUIUtility.GetControlID(GUI.s_ScrollviewHash, FocusType.Passive);
151159

0 commit comments

Comments
 (0)