From 23483a61086486aa5071d744b6f05bae84fc1976 Mon Sep 17 00:00:00 2001
From: Sinai
Date: Thu, 29 Apr 2021 21:45:45 +1000
Subject: [PATCH 1/5] Add aggressive mouse unlock option using
WaitForEndOfFrame
---
src/Core/Config/ConfigManager.cs | 5 +++++
src/Core/Input/CursorUnlocker.cs | 31 +++++++++++++++++++++++++++++++
src/ExplorerCore.cs | 2 +-
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/src/Core/Config/ConfigManager.cs b/src/Core/Config/ConfigManager.cs
index 44d1ee0..8ab401a 100644
--- a/src/Core/Config/ConfigManager.cs
+++ b/src/Core/Config/ConfigManager.cs
@@ -19,6 +19,7 @@ namespace UnityExplorer.Core.Config
public static ConfigElement Main_Menu_Toggle;
public static ConfigElement Force_Unlock_Mouse;
+ public static ConfigElement Aggressive_Force_Unlock;
public static ConfigElement Default_Tab;
public static ConfigElement Default_Page_Limit;
public static ConfigElement Default_Output_Path;
@@ -78,6 +79,10 @@ namespace UnityExplorer.Core.Config
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
true);
+ Aggressive_Force_Unlock = new ConfigElement("Aggressive Mouse Unlock",
+ "Use WaitForEndOfFrame to aggressively force the Mouse to be unlocked (requires game restart).",
+ false);
+
Default_Page_Limit = new ConfigElement("Default Page Limit",
"The default maximum number of elements per 'page' in UnityExplorer.",
25);
diff --git a/src/Core/Input/CursorUnlocker.cs b/src/Core/Input/CursorUnlocker.cs
index ab5dc9a..d5733e7 100644
--- a/src/Core/Input/CursorUnlocker.cs
+++ b/src/Core/Input/CursorUnlocker.cs
@@ -7,6 +7,7 @@ using BF = System.Reflection.BindingFlags;
using UnityExplorer.Core.Config;
using UnityExplorer.Core;
using UnityExplorer.UI;
+using System.Collections;
#if ML
using Harmony;
#else
@@ -48,6 +49,36 @@ namespace UnityExplorer.Core.Input
Unlock = ConfigManager.Force_Unlock_Mouse.Value;
ConfigManager.Force_Unlock_Mouse.OnValueChanged += (bool val) => { Unlock = val; };
+
+ if (ConfigManager.Aggressive_Force_Unlock.Value)
+ SetupAggressiveUnlock();
+ }
+
+ public static void SetupAggressiveUnlock()
+ {
+ try
+ {
+ RuntimeProvider.Instance.StartCoroutine(AggressiveUnlockCoroutine());
+ }
+ catch (Exception ex)
+ {
+ ExplorerCore.LogWarning($"Exception setting up Camera.onPostRender callback: {ex}");
+ }
+ }
+
+ private static readonly WaitForEndOfFrame _waitForEndOfFrame = new WaitForEndOfFrame();
+
+ private static IEnumerator AggressiveUnlockCoroutine()
+ {
+ while (true)
+ {
+ ExplorerCore.Log("Yielding end of frame");
+ yield return _waitForEndOfFrame;
+ ExplorerCore.Log("Yielded");
+
+ if (UIManager.ShowMenu)
+ UpdateCursorControl();
+ }
}
public static void UpdateCursorControl()
diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs
index 47b7cff..e72dfd4 100644
--- a/src/ExplorerCore.cs
+++ b/src/ExplorerCore.cs
@@ -14,7 +14,7 @@ namespace UnityExplorer
public class ExplorerCore
{
public const string NAME = "UnityExplorer";
- public const string VERSION = "3.3.12";
+ public const string VERSION = "3.3.13";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";
From ad055b4383d35035a0e7265d46412667c7f2d8d1 Mon Sep 17 00:00:00 2001
From: Sinai <49360850+sinai-dev@users.noreply.github.com>
Date: Thu, 29 Apr 2021 21:54:13 +1000
Subject: [PATCH 2/5] Update README.md
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 7fc463e..41ed3e7 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,10 @@
An in-game explorer and a suite of debugging tools for IL2CPP and Mono Unity games, to aid with modding development.
+
+ Supports most Unity games from versions 5.2 to 2020+.
+
+
## Releases [](../../releases/latest) [](../../releases) [](../../releases/latest)
| Mod Loader | IL2CPP | Mono |
From 4b8298fd2e3a3767c5567bbfa54ddfee69d9592b Mon Sep 17 00:00:00 2001
From: Sinai
Date: Fri, 30 Apr 2021 00:12:41 +1000
Subject: [PATCH 3/5] Update CursorUnlocker.cs
---
src/Core/Input/CursorUnlocker.cs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/Core/Input/CursorUnlocker.cs b/src/Core/Input/CursorUnlocker.cs
index d5733e7..4a535f0 100644
--- a/src/Core/Input/CursorUnlocker.cs
+++ b/src/Core/Input/CursorUnlocker.cs
@@ -62,7 +62,7 @@ namespace UnityExplorer.Core.Input
}
catch (Exception ex)
{
- ExplorerCore.LogWarning($"Exception setting up Camera.onPostRender callback: {ex}");
+ ExplorerCore.LogWarning($"Exception setting up Aggressive Mouse Unlock: {ex}");
}
}
@@ -72,9 +72,7 @@ namespace UnityExplorer.Core.Input
{
while (true)
{
- ExplorerCore.Log("Yielding end of frame");
yield return _waitForEndOfFrame;
- ExplorerCore.Log("Yielded");
if (UIManager.ShowMenu)
UpdateCursorControl();
From ea1e183c4aaeddc0c3beb8498cce47bcfdedd344 Mon Sep 17 00:00:00 2001
From: Sinai
Date: Sat, 1 May 2021 16:32:11 +1000
Subject: [PATCH 4/5] Fix onValueChanged bursts
---
src/ExplorerCore.cs | 2 +-
src/UI/Main/CSConsole/CSharpConsole.cs | 25 ++++---------------------
2 files changed, 5 insertions(+), 22 deletions(-)
diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs
index e72dfd4..6683e83 100644
--- a/src/ExplorerCore.cs
+++ b/src/ExplorerCore.cs
@@ -14,7 +14,7 @@ namespace UnityExplorer
public class ExplorerCore
{
public const string NAME = "UnityExplorer";
- public const string VERSION = "3.3.13";
+ public const string VERSION = "3.3.14";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";
diff --git a/src/UI/Main/CSConsole/CSharpConsole.cs b/src/UI/Main/CSConsole/CSharpConsole.cs
index 9a13ba5..c495f57 100644
--- a/src/UI/Main/CSConsole/CSharpConsole.cs
+++ b/src/UI/Main/CSConsole/CSharpConsole.cs
@@ -199,23 +199,8 @@ The following helper methods are available:
InputField.onValueChanged.AddListener((string s) => { OnInputChanged(s); });
}
- internal static bool IsUserCopyPasting()
- {
- return (InputManager.GetKey(KeyCode.LeftControl) || InputManager.GetKey(KeyCode.RightControl))
- && InputManager.GetKeyDown(KeyCode.V);
- }
-
public void UpdateConsole()
{
- if (s_copyPasteBuffer != null)
- {
- if (!IsUserCopyPasting())
- {
- OnInputChanged(s_copyPasteBuffer);
-
- s_copyPasteBuffer = null;
- }
- }
if (EnableCtrlRShortcut)
{
@@ -288,16 +273,14 @@ The following helper methods are available:
AutoCompleter.ClearAutocompletes();
}
- internal static string s_copyPasteBuffer;
+ private static float s_timeOfLastUpdate;
public void OnInputChanged(string newText, bool forceUpdate = false)
{
- if (IsUserCopyPasting())
- {
- //Console.WriteLine("Copy+Paste detected!");
- s_copyPasteBuffer = newText;
+ if (Time.time <= s_timeOfLastUpdate)
return;
- }
+
+ s_timeOfLastUpdate = Time.time;
if (EnableAutoIndent)
UpdateIndent(newText);
From 1c5306b7c81ff732523b0aeffc88143e0496db6e Mon Sep 17 00:00:00 2001
From: Sinai
Date: Mon, 3 May 2021 00:59:39 +1000
Subject: [PATCH 5/5] Fix the onValueChange throttling affecting internal
features
---
src/ExplorerCore.cs | 2 +-
src/UI/Main/CSConsole/CSharpConsole.cs | 22 +++++++++++++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs
index 6683e83..ee2d8d3 100644
--- a/src/ExplorerCore.cs
+++ b/src/ExplorerCore.cs
@@ -14,7 +14,7 @@ namespace UnityExplorer
public class ExplorerCore
{
public const string NAME = "UnityExplorer";
- public const string VERSION = "3.3.14";
+ public const string VERSION = "3.3.15";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";
diff --git a/src/UI/Main/CSConsole/CSharpConsole.cs b/src/UI/Main/CSConsole/CSharpConsole.cs
index c495f57..43d66a0 100644
--- a/src/UI/Main/CSConsole/CSharpConsole.cs
+++ b/src/UI/Main/CSConsole/CSharpConsole.cs
@@ -201,6 +201,8 @@ The following helper methods are available:
public void UpdateConsole()
{
+ if (Time.time > s_timeOfLastInternalSet)
+ Writing = false;
if (EnableCtrlRShortcut)
{
@@ -259,6 +261,8 @@ The following helper methods are available:
public void UseAutocomplete(string suggestion)
{
+ Writing = true;
+
string input = InputField.text;
input = input.Insert(m_lastCaretPos, suggestion);
InputField.text = input;
@@ -274,10 +278,22 @@ The following helper methods are available:
}
private static float s_timeOfLastUpdate;
+ private static bool Writing
+ {
+ get => s_writing;
+ set
+ {
+ if (value)
+ s_timeOfLastInternalSet = Time.time;
+ s_writing = value;
+ }
+ }
+ private static bool s_writing;
+ private static float s_timeOfLastInternalSet;
public void OnInputChanged(string newText, bool forceUpdate = false)
{
- if (Time.time <= s_timeOfLastUpdate)
+ if (!Writing && Time.time <= s_timeOfLastUpdate)
return;
s_timeOfLastUpdate = Time.time;
@@ -285,6 +301,8 @@ The following helper methods are available:
if (EnableAutoIndent)
UpdateIndent(newText);
+ Writing = true;
+
if (!forceUpdate && string.IsNullOrEmpty(newText))
inputHighlightText.text = string.Empty;
else
@@ -361,6 +379,8 @@ The following helper methods are available:
private void AutoIndentCaret()
{
+ Writing = true;
+
if (CurrentIndent > 0)
{
string indent = GetAutoIndentTab(CurrentIndent);