From 9cf62c32507fe607c023448da79b2bca80b928fd Mon Sep 17 00:00:00 2001 From: Sinai <49360850+sinai-dev@users.noreply.github.com> Date: Tue, 19 Apr 2022 18:05:55 +1000 Subject: [PATCH] Bump UniverseLib, fix EventSystem issue --- src/CSConsole/ConsoleController.cs | 66 +----------------------------- src/ExplorerCore.cs | 2 +- src/UI/Panels/FreeCamPanel.cs | 6 +-- src/UnityExplorer.csproj | 4 +- 4 files changed, 8 insertions(+), 70 deletions(-) diff --git a/src/CSConsole/ConsoleController.cs b/src/CSConsole/ConsoleController.cs index 748e99e..d696d83 100644 --- a/src/CSConsole/ConsoleController.cs +++ b/src/CSConsole/ConsoleController.cs @@ -61,8 +61,6 @@ namespace UnityExplorer.CSConsole public static void Init() { - InitEventSystemPropertyHandlers(); - // Make sure console is supported on this platform try { @@ -386,77 +384,17 @@ namespace UnityExplorer.CSConsole RuntimeHelper.StartCoroutine(SetCaretCoroutine(caretPosition)); } - static void InitEventSystemPropertyHandlers() - { - try - { - foreach (MemberInfo member in typeof(EventSystem).GetMembers(AccessTools.all)) - { - if (member.Name == "m_CurrentSelected") - { - Type backingType; - if (member.MemberType == MemberTypes.Property) - backingType = (member as PropertyInfo).PropertyType; - else - backingType = (member as FieldInfo).FieldType; - - usingEventSystemDictionaryMembers = ReflectionUtility.IsDictionary(backingType); - break; - } - } - } - catch (Exception ex) - { - ExplorerCore.LogWarning($"Exception checking EventSystem property backing type: {ex}"); - } - } - - static bool usingEventSystemDictionaryMembers; - - static readonly AmbiguousMemberHandler m_CurrentSelected_Handler_Normal - = new(true, true, "m_CurrentSelected", "m_currentSelected"); - static readonly AmbiguousMemberHandler> m_CurrentSelected_Handler_Dictionary - = new(true, true, "m_CurrentSelected", "m_currentSelected"); - - static readonly AmbiguousMemberHandler m_SelectionGuard_Handler_Normal - = new(true, true, "m_SelectionGuard", "m_selectionGuard"); - static readonly AmbiguousMemberHandler> m_SelectionGuard_Handler_Dictionary - = new(true, true, "m_SelectionGuard", "m_selectionGuard"); - - static void SetCurrentSelectedGameObject(EventSystem instance, GameObject value) - { - instance.SetSelectedGameObject(value); - - if (usingEventSystemDictionaryMembers) - m_CurrentSelected_Handler_Dictionary.GetValue(instance)[0] = value; - else - m_CurrentSelected_Handler_Normal.SetValue(instance, value); - } - - static void SetSelectionGuard(EventSystem instance, bool value) - { - if (usingEventSystemDictionaryMembers) - m_SelectionGuard_Handler_Dictionary.GetValue(instance)[0] = value; - else - m_SelectionGuard_Handler_Normal.SetValue(instance, value); - } - private static IEnumerator SetCaretCoroutine(int caretPosition) { Color color = Input.Component.selectionColor; color.a = 0f; Input.Component.selectionColor = color; - try { SetCurrentSelectedGameObject(CursorUnlocker.CurrentEventSystem, null); } - catch (Exception ex) { ExplorerCore.Log($"Failed removing selected object: {ex}"); } + EventSystemHelper.SetSelectedGameObject(null); yield return null; // ~~~~~~~ YIELD FRAME ~~~~~~~~~ - try { SetSelectionGuard(CursorUnlocker.CurrentEventSystem, false); } - catch (Exception ex) { ExplorerCore.Log($"Failed setting selection guard: {ex}"); } - - try { SetCurrentSelectedGameObject(CursorUnlocker.CurrentEventSystem, Input.GameObject); } - catch (Exception ex) { ExplorerCore.Log($"Failed setting selected gameobject: {ex}"); } + EventSystemHelper.SetSelectedGameObject(null); yield return null; // ~~~~~~~ YIELD FRAME ~~~~~~~~~ diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index c41814d..575dc2c 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -14,7 +14,7 @@ namespace UnityExplorer public static class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "4.7.3"; + public const string VERSION = "4.7.4"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; diff --git a/src/UI/Panels/FreeCamPanel.cs b/src/UI/Panels/FreeCamPanel.cs index 14e9605..d5c0b20 100644 --- a/src/UI/Panels/FreeCamPanel.cs +++ b/src/UI/Panels/FreeCamPanel.cs @@ -182,7 +182,7 @@ namespace UnityExplorer.UI.Panels void ToggleButton_OnClick() { - InputManager.SetSelectedEventSystemGameObject(null); + EventSystemHelper.SetSelectedGameObject(null); if (inFreeCamMode) EndFreecam(); @@ -194,7 +194,7 @@ namespace UnityExplorer.UI.Panels private void PositionInput_OnEndEdit(string input) { - InputManager.SetSelectedEventSystemGameObject(null); + EventSystemHelper.SetSelectedGameObject(null); if (!ParseUtility.TryParse(input, out Vector3 parsed, out Exception parseEx)) { @@ -208,7 +208,7 @@ namespace UnityExplorer.UI.Panels private void MoveSpeedInput_OnEndEdit(string input) { - InputManager.SetSelectedEventSystemGameObject(null); + EventSystemHelper.SetSelectedGameObject(null); if (!ParseUtility.TryParse(input, out float parsed, out Exception parseEx)) { diff --git a/src/UnityExplorer.csproj b/src/UnityExplorer.csproj index 4fd31a2..a158701 100644 --- a/src/UnityExplorer.csproj +++ b/src/UnityExplorer.csproj @@ -79,11 +79,11 @@ - + - +