Compare commits

..

2 Commits

Author SHA1 Message Date
3628f3db31 Fix event system control 2021-04-09 01:46:26 +10:00
d39fea69c3 Better InputSystem Key enum resolving 2021-04-07 20:54:08 +10:00
4 changed files with 28 additions and 16 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

@ -6,6 +6,7 @@ using UnityEngine.EventSystems;
using UnityExplorer.UI; using UnityExplorer.UI;
using System.Collections.Generic; using System.Collections.Generic;
using UnityExplorer.UI.Inspectors; using UnityExplorer.UI.Inspectors;
using System.Linq;
namespace UnityExplorer.Core.Input namespace UnityExplorer.Core.Input
{ {
@ -84,16 +85,28 @@ namespace UnityExplorer.Core.Input
} }
internal static Dictionary<KeyCode, object> ActualKeyDict = new Dictionary<KeyCode, object>(); internal static Dictionary<KeyCode, object> ActualKeyDict = new Dictionary<KeyCode, object>();
internal static Dictionary<string, string> enumNameFixes = new Dictionary<string, string>
{
{ "Control", "Ctrl" },
{ "Return", "Enter" },
{ "Alpha", "Digit" },
{ "Keypad", "Numpad" },
{ "Numlock", "NumLock" },
{ "Print", "PrintScreen" },
{ "BackQuote", "Backquote" }
};
internal object GetActualKey(KeyCode key) internal object GetActualKey(KeyCode key)
{ {
if (!ActualKeyDict.ContainsKey(key)) if (!ActualKeyDict.ContainsKey(key))
{ {
var s = key.ToString(); var s = key.ToString();
if (s.Contains("Control")) try
s = s.Replace("Control", "Ctrl"); {
else if (s.Contains("Return")) if (enumNameFixes.First(it => s.Contains(it.Key)) is KeyValuePair<string, string> entry)
s = "Enter"; s = s.Replace(entry.Key, entry.Value);
}
catch { }
var parsed = Enum.Parse(TKey, s); var parsed = Enum.Parse(TKey, s);
var actualKey = m_kbIndexer.GetValue(CurrentKeyboard, new object[] { parsed }); var actualKey = m_kbIndexer.GetValue(CurrentKeyboard, new object[] { parsed });

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";
@ -48,7 +48,7 @@ namespace UnityExplorer
Log($"{NAME} {VERSION} initialized."); Log($"{NAME} {VERSION} initialized.");
InspectorManager.Instance.Inspect(typeof(TestClass)); //InspectorManager.Instance.Inspect(typeof(TestClass));
} }
public static void Update() public static void Update()

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
{ {