Fix event system control

This commit is contained in:
Sinai 2021-04-09 01:46:26 +10:00
parent d39fea69c3
commit 3628f3db31
3 changed files with 10 additions and 11 deletions

View File

@ -89,34 +89,29 @@ namespace UnityExplorer.Core.Input
public static void SetEventSystem() public static void SetEventSystem()
{ {
// not overriding EventSystem for new InputSystem, dont seem to need to.
if (InputManager.CurrentType == InputType.InputSystem) if (InputManager.CurrentType == InputType.InputSystem)
return; return;
// Disable current event system object if (EventSystem.current && EventSystem.current != UIManager.EventSys)
if (m_lastEventSystem || EventSystem.current)
{ {
if (!m_lastEventSystem) m_lastEventSystem = EventSystem.current;
m_lastEventSystem = EventSystem.current;
m_lastEventSystem.enabled = false; m_lastEventSystem.enabled = false;
} }
// Set to our current system // Set to our current system
m_settingEventSystem = true; m_settingEventSystem = true;
EventSystem.current = UIManager.EventSys;
UIManager.EventSys.enabled = true; UIManager.EventSys.enabled = true;
EventSystem.current = UIManager.EventSys;
InputManager.ActivateUIModule(); InputManager.ActivateUIModule();
m_settingEventSystem = false; m_settingEventSystem = false;
} }
public static void ReleaseEventSystem() public static void ReleaseEventSystem()
{ {
// not overriding EventSystem for new InputSystem, dont seem to need to.
if (InputManager.CurrentType == InputType.InputSystem) if (InputManager.CurrentType == InputType.InputSystem)
return; return;
if (m_lastEventSystem) if (m_lastEventSystem && m_lastEventSystem.gameObject.activeSelf)
{ {
m_lastEventSystem.enabled = true; m_lastEventSystem.enabled = true;
@ -153,13 +148,16 @@ namespace UnityExplorer.Core.Input
public static void Prefix_EventSystem_set_current(ref EventSystem value) public static void Prefix_EventSystem_set_current(ref EventSystem value)
{ {
if (!m_settingEventSystem) if (!m_settingEventSystem && value != UIManager.EventSys)
{ {
m_lastEventSystem = value; m_lastEventSystem = value;
m_lastInputModule = value?.currentInputModule; m_lastInputModule = value?.currentInputModule;
if (ShouldActuallyUnlock) if (ShouldActuallyUnlock)
{
value = UIManager.EventSys; value = UIManager.EventSys;
value.enabled = true;
}
} }
} }

View File

@ -13,7 +13,7 @@ namespace UnityExplorer
public class ExplorerCore public class ExplorerCore
{ {
public const string NAME = "UnityExplorer"; public const string NAME = "UnityExplorer";
public const string VERSION = "3.3.9"; public const string VERSION = "3.3.10";
public const string AUTHOR = "Sinai"; public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer"; public const string GUID = "com.sinai.unityexplorer";

View File

@ -13,6 +13,7 @@ using UnityExplorer.Loader.ML;
[assembly: MelonInfo(typeof(ExplorerMelonMod), ExplorerCore.NAME, ExplorerCore.VERSION, ExplorerCore.AUTHOR)] [assembly: MelonInfo(typeof(ExplorerMelonMod), ExplorerCore.NAME, ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
[assembly: MelonGame(null, null)] [assembly: MelonGame(null, null)]
//[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.UNIVERSAL)]
namespace UnityExplorer namespace UnityExplorer
{ {