Fix onValueChanged bursts

This commit is contained in:
Sinai
2021-05-01 16:32:11 +10:00
parent 8080129d58
commit ea1e183c4a
2 changed files with 5 additions and 22 deletions

View File

@ -14,7 +14,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.13"; public const string VERSION = "3.3.14";
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

@ -199,23 +199,8 @@ The following helper methods are available:
InputField.onValueChanged.AddListener((string s) => { OnInputChanged(s); }); 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() public void UpdateConsole()
{ {
if (s_copyPasteBuffer != null)
{
if (!IsUserCopyPasting())
{
OnInputChanged(s_copyPasteBuffer);
s_copyPasteBuffer = null;
}
}
if (EnableCtrlRShortcut) if (EnableCtrlRShortcut)
{ {
@ -288,16 +273,14 @@ The following helper methods are available:
AutoCompleter.ClearAutocompletes(); AutoCompleter.ClearAutocompletes();
} }
internal static string s_copyPasteBuffer; private static float s_timeOfLastUpdate;
public void OnInputChanged(string newText, bool forceUpdate = false) public void OnInputChanged(string newText, bool forceUpdate = false)
{ {
if (IsUserCopyPasting()) if (Time.time <= s_timeOfLastUpdate)
{
//Console.WriteLine("Copy+Paste detected!");
s_copyPasteBuffer = newText;
return; return;
}
s_timeOfLastUpdate = Time.time;
if (EnableAutoIndent) if (EnableAutoIndent)
UpdateIndent(newText); UpdateIndent(newText);