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

Commit 852ca8e

Browse files
committed
New attempt at fixing conflicting EventSystem problems in IL2CPP
1 parent 7386eca commit 852ca8e

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

src/ExplorerCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace UnityExplorer
1616
public class ExplorerCore
1717
{
1818
public const string NAME = "UnityExplorer";
19-
public const string VERSION = "3.1.1";
19+
public const string VERSION = "3.1.2";
2020
public const string AUTHOR = "Sinai";
2121
public const string GUID = "com.sinai.unityexplorer";
2222
public const string EXPLORER_FOLDER = @"Mods\UnityExplorer";

src/UI/ForceUnlockCursor.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ private static void SetupPatches()
8787
new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_visible))),
8888
true);
8989

90-
#if BIE
91-
#if CPP
92-
// temporarily disabling this patch in BepInEx il2cpp as it's causing a crash in some games.
93-
return;
94-
#endif
95-
#endif
9690
TryPatch(typeof(EventSystem),
9791
"current",
9892
new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_EventSystem_set_current))),
@@ -164,9 +158,22 @@ public static void UpdateCursorControl()
164158

165159
public static void SetEventSystem()
166160
{
161+
// temp disabled for new InputSystem
167162
if (InputManager.CurrentType == InputType.InputSystem)
168163
return;
169164

165+
// Disable current event system object
166+
if (m_lastEventSystem || EventSystem.current)
167+
{
168+
if (!m_lastEventSystem)
169+
m_lastEventSystem = EventSystem.current;
170+
171+
//ExplorerCore.Log("Disabling current event system...");
172+
m_lastEventSystem.enabled = false;
173+
m_lastEventSystem.gameObject.SetActive(false);
174+
}
175+
176+
// Set to our current system
170177
m_settingEventSystem = true;
171178
EventSystem.current = UIManager.EventSys;
172179
InputManager.ActivateUIModule();
@@ -180,6 +187,9 @@ public static void ReleaseEventSystem()
180187

181188
if (m_lastEventSystem)
182189
{
190+
m_lastEventSystem.enabled = true;
191+
m_lastEventSystem.gameObject.SetActive(true);
192+
183193
m_settingEventSystem = true;
184194
EventSystem.current = m_lastEventSystem;
185195
m_lastInputModule?.ActivateModule();

src/UI/UIManager.cs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,46 +45,27 @@ public static void OnSceneChange()
4545
SceneExplorer.Instance?.OnSceneChange();
4646
SearchPage.Instance?.OnSceneChange();
4747
}
48-
49-
#if CPP
50-
internal static float s_timeOfLastClick;
51-
#endif
5248
public static void Update()
5349
{
5450
MainMenu.Instance?.Update();
5551

5652
if (EventSys)
5753
{
5854
if (EventSystem.current != EventSys)
59-
{
6055
ForceUnlockCursor.SetEventSystem();
61-
}
62-
6356
#if CPP
64-
// Fix for games which override the InputModule pointer events (eg, VRChat)
57+
// Some IL2CPP games behave weird with multiple UI Input Systems, some fixes for them.
6558
var evt = InputManager.InputPointerEvent;
6659
if (evt != null)
6760
{
68-
if (Time.realtimeSinceStartup - s_timeOfLastClick > 0.1f)
69-
{
70-
s_timeOfLastClick = Time.realtimeSinceStartup;
71-
72-
if (!evt.eligibleForClick && evt.selectedObject)
73-
evt.eligibleForClick = true;
74-
}
75-
else
76-
{
77-
if (evt.eligibleForClick)
78-
evt.eligibleForClick = false;
79-
}
61+
if (!evt.eligibleForClick && evt.selectedObject)
62+
evt.eligibleForClick = true;
8063
}
8164
#endif
8265
}
8366

8467
if (PanelDragger.Instance != null)
85-
{
8668
PanelDragger.Instance.Update();
87-
}
8869

8970
for (int i = 0; i < SliderScrollbar.Instances.Count; i++)
9071
{

0 commit comments

Comments
 (0)