From 7a4c7eb4986c35d896173020c57ee50ecd022bcf Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Fri, 13 Nov 2020 23:37:04 +1100 Subject: [PATCH] Fix vertices overflow on debug console, move UISyntaxHighlight --- src/UI/Modules/DebugConsole.cs | 11 ++++++++++- src/UI/{Shared => }/UISyntaxHighlight.cs | 6 ++---- src/UnityExplorer.csproj | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) rename src/UI/{Shared => }/UISyntaxHighlight.cs (96%) diff --git a/src/UI/Modules/DebugConsole.cs b/src/UI/Modules/DebugConsole.cs index 41f2dae..2e5f63d 100644 --- a/src/UI/Modules/DebugConsole.cs +++ b/src/UI/Modules/DebugConsole.cs @@ -29,6 +29,7 @@ namespace UnityExplorer.UI.Modules internal static readonly List s_preInitMessages = new List(); private InputField m_textInput; + internal const int MAX_TEXT_LEN = 10000; public DebugConsole(GameObject parent) { @@ -102,7 +103,15 @@ namespace UnityExplorer.UI.Modules message = $"{message}"; if (Instance?.m_textInput) - Instance.m_textInput.text = $"{message}\n{Instance.m_textInput.text}"; + { + var input = Instance.m_textInput; + var wanted = $"{message}\n{input.text}"; + + if (wanted.Length > MAX_TEXT_LEN) + wanted = wanted.Substring(0, MAX_TEXT_LEN); + + input.text = wanted; + } else s_preInitMessages.Add(message); } diff --git a/src/UI/Shared/UISyntaxHighlight.cs b/src/UI/UISyntaxHighlight.cs similarity index 96% rename from src/UI/Shared/UISyntaxHighlight.cs rename to src/UI/UISyntaxHighlight.cs index 723e9a3..889b16c 100644 --- a/src/UI/Shared/UISyntaxHighlight.cs +++ b/src/UI/UISyntaxHighlight.cs @@ -4,7 +4,7 @@ using System.Reflection; using UnityEngine; using UnityExplorer.Unstrip; -namespace UnityExplorer.UI.Shared +namespace UnityExplorer.UI { public class UISyntaxHighlight { @@ -47,9 +47,7 @@ namespace UnityExplorer.UI.Shared { string ret = ""; - if (type.IsGenericParameter - || type.GetGenericArguments().Any(it => it.IsGenericParameter) - || (type.HasElementType && type.GetElementType().IsGenericParameter)) + if (type.IsGenericParameter || (type.HasElementType && type.GetElementType().IsGenericParameter)) { ret = $"{type.Name}"; } diff --git a/src/UnityExplorer.csproj b/src/UnityExplorer.csproj index 9076c31..5ddfb08 100644 --- a/src/UnityExplorer.csproj +++ b/src/UnityExplorer.csproj @@ -379,7 +379,7 @@ - +