mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-06 01:23:31 +08:00
New attempt at fixing conflicting EventSystem problems in IL2CPP
This commit is contained in:
parent
7386eca0c2
commit
852ca8e9eb
@ -16,7 +16,7 @@ namespace UnityExplorer
|
||||
public class ExplorerCore
|
||||
{
|
||||
public const string NAME = "UnityExplorer";
|
||||
public const string VERSION = "3.1.1";
|
||||
public const string VERSION = "3.1.2";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.unityexplorer";
|
||||
public const string EXPLORER_FOLDER = @"Mods\UnityExplorer";
|
||||
|
@ -87,12 +87,6 @@ namespace UnityExplorer.UI
|
||||
new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_visible))),
|
||||
true);
|
||||
|
||||
#if BIE
|
||||
#if CPP
|
||||
// temporarily disabling this patch in BepInEx il2cpp as it's causing a crash in some games.
|
||||
return;
|
||||
#endif
|
||||
#endif
|
||||
TryPatch(typeof(EventSystem),
|
||||
"current",
|
||||
new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_EventSystem_set_current))),
|
||||
@ -164,9 +158,22 @@ namespace UnityExplorer.UI
|
||||
|
||||
public static void SetEventSystem()
|
||||
{
|
||||
// temp disabled for new InputSystem
|
||||
if (InputManager.CurrentType == InputType.InputSystem)
|
||||
return;
|
||||
|
||||
// Disable current event system object
|
||||
if (m_lastEventSystem || EventSystem.current)
|
||||
{
|
||||
if (!m_lastEventSystem)
|
||||
m_lastEventSystem = EventSystem.current;
|
||||
|
||||
//ExplorerCore.Log("Disabling current event system...");
|
||||
m_lastEventSystem.enabled = false;
|
||||
m_lastEventSystem.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Set to our current system
|
||||
m_settingEventSystem = true;
|
||||
EventSystem.current = UIManager.EventSys;
|
||||
InputManager.ActivateUIModule();
|
||||
@ -180,6 +187,9 @@ namespace UnityExplorer.UI
|
||||
|
||||
if (m_lastEventSystem)
|
||||
{
|
||||
m_lastEventSystem.enabled = true;
|
||||
m_lastEventSystem.gameObject.SetActive(true);
|
||||
|
||||
m_settingEventSystem = true;
|
||||
EventSystem.current = m_lastEventSystem;
|
||||
m_lastInputModule?.ActivateModule();
|
||||
|
@ -45,10 +45,6 @@ namespace UnityExplorer.UI
|
||||
SceneExplorer.Instance?.OnSceneChange();
|
||||
SearchPage.Instance?.OnSceneChange();
|
||||
}
|
||||
|
||||
#if CPP
|
||||
internal static float s_timeOfLastClick;
|
||||
#endif
|
||||
public static void Update()
|
||||
{
|
||||
MainMenu.Instance?.Update();
|
||||
@ -56,35 +52,20 @@ namespace UnityExplorer.UI
|
||||
if (EventSys)
|
||||
{
|
||||
if (EventSystem.current != EventSys)
|
||||
{
|
||||
ForceUnlockCursor.SetEventSystem();
|
||||
}
|
||||
|
||||
#if CPP
|
||||
// Fix for games which override the InputModule pointer events (eg, VRChat)
|
||||
// Some IL2CPP games behave weird with multiple UI Input Systems, some fixes for them.
|
||||
var evt = InputManager.InputPointerEvent;
|
||||
if (evt != null)
|
||||
{
|
||||
if (Time.realtimeSinceStartup - s_timeOfLastClick > 0.1f)
|
||||
{
|
||||
s_timeOfLastClick = Time.realtimeSinceStartup;
|
||||
|
||||
if (!evt.eligibleForClick && evt.selectedObject)
|
||||
evt.eligibleForClick = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (evt.eligibleForClick)
|
||||
evt.eligibleForClick = false;
|
||||
}
|
||||
if (!evt.eligibleForClick && evt.selectedObject)
|
||||
evt.eligibleForClick = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (PanelDragger.Instance != null)
|
||||
{
|
||||
PanelDragger.Instance.Update();
|
||||
}
|
||||
|
||||
for (int i = 0; i < SliderScrollbar.Instances.Count; i++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user