From 97325a5f3add13edff9bbcb0ff0ecfe3aed18b7d Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Tue, 15 Dec 2020 19:32:50 +1100 Subject: [PATCH] Fix an issue causing duplicated clicks in some IL2CPP games, fix setting Component.enabled in IL2CPP --- src/ExplorerCore.cs | 2 +- src/Inspectors/GameObjects/ComponentList.cs | 5 ++++- src/UI/Modules/SearchPage.cs | 9 --------- src/UI/UIManager.cs | 18 ++++++++++++++++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index 7f565e0..adb050b 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -16,7 +16,7 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.1.0"; + public const string VERSION = "3.1.1"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; public const string EXPLORER_FOLDER = @"Mods\UnityExplorer"; diff --git a/src/Inspectors/GameObjects/ComponentList.cs b/src/Inspectors/GameObjects/ComponentList.cs index 1adac26..7b35208 100644 --- a/src/Inspectors/GameObjects/ComponentList.cs +++ b/src/Inspectors/GameObjects/ComponentList.cs @@ -111,8 +111,11 @@ namespace UnityExplorer.Inspectors.GameObjects internal static void OnCompToggleClicked(int index, bool value) { var comp = s_compShortlist[index]; - +#if CPP + comp.TryCast().enabled = value; +#else (comp as Behaviour).enabled = value; +#endif } internal static void OnCompListObjectClicked(int index) diff --git a/src/UI/Modules/SearchPage.cs b/src/UI/Modules/SearchPage.cs index 7d5e57b..5d1b09e 100644 --- a/src/UI/Modules/SearchPage.cs +++ b/src/UI/Modules/SearchPage.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -//using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; @@ -51,8 +50,6 @@ namespace UnityExplorer.UI.Modules private SceneFilter m_sceneFilter; private ChildFilter m_childFilter; - internal bool m_isStaticClassSearching; - // ui elements private Text m_resultCountText; @@ -257,8 +254,6 @@ namespace UnityExplorer.UI.Modules internal void StaticClassSearch() { - m_isStaticClassSearching = true; - var list = new List(); var nameFilter = ""; @@ -295,8 +290,6 @@ namespace UnityExplorer.UI.Modules private void SingletonSearch() { - m_isStaticClassSearching = false; - var instances = new List(); var nameFilter = ""; @@ -356,8 +349,6 @@ namespace UnityExplorer.UI.Modules internal void UnityObjectSearch() { - m_isStaticClassSearching = false; - Type searchType = null; switch (m_context) { diff --git a/src/UI/UIManager.cs b/src/UI/UIManager.cs index 69de64a..3e7c1af 100644 --- a/src/UI/UIManager.cs +++ b/src/UI/UIManager.cs @@ -46,6 +46,9 @@ namespace UnityExplorer.UI SearchPage.Instance?.OnSceneChange(); } +#if CPP + internal static float s_timeOfLastClick; +#endif public static void Update() { MainMenu.Instance?.Update(); @@ -54,6 +57,7 @@ namespace UnityExplorer.UI { if (EventSystem.current != EventSys) { + ExplorerCore.Log("Forcing EventSystem to UnityExplorer's"); ForceUnlockCursor.SetEventSystem(); } @@ -62,8 +66,18 @@ namespace UnityExplorer.UI var evt = InputManager.InputPointerEvent; if (evt != null) { - if (!evt.eligibleForClick && evt.selectedObject) - evt.eligibleForClick = true; + 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; + } } #endif }