From 604c499822de503338c53f275b2a95311cb93e3d Mon Sep 17 00:00:00 2001 From: Sinai Date: Fri, 26 Mar 2021 07:31:30 +1100 Subject: [PATCH] Add Reset button to C# Console --- src/ExplorerCore.cs | 2 +- src/UI/Main/CSConsole/CSharpConsole.cs | 52 +++++++++++++++++++++----- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index db88cbd..8682cd4 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -17,7 +17,7 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.2.8"; + public const string VERSION = "3.2.9"; 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 79190b7..f75e937 100644 --- a/src/UI/Main/CSConsole/CSharpConsole.cs +++ b/src/UI/Main/CSConsole/CSharpConsole.cs @@ -12,6 +12,7 @@ using UnityEngine.UI; using UnityExplorer.UI.Reusable; using UnityExplorer.UI.Main.CSConsole; using UnityExplorer.Core; +using UnityExplorer.Core.Unity; #if CPP using UnityExplorer.Core.Runtime.Il2Cpp; #endif @@ -56,13 +57,10 @@ namespace UnityExplorer.UI.Main.CSConsole DummyBehaviour.Setup(); #endif - ResetConsole(); + ResetConsole(false); // Make sure compiler is supported on this platform Evaluator.Compile(""); - foreach (string use in DefaultUsing) - AddUsing(use); - return true; } catch (Exception e) @@ -79,7 +77,7 @@ namespace UnityExplorer.UI.Main.CSConsole } } - public void ResetConsole() + public void ResetConsole(bool log = true) { if (Evaluator != null) Evaluator.Dispose(); @@ -89,6 +87,12 @@ namespace UnityExplorer.UI.Main.CSConsole Evaluator = new ScriptEvaluator(new StringWriter(m_evalLogBuilder)) { InteractiveBaseClass = typeof(ScriptInteraction) }; UsingDirectives = new List(); + + foreach (string use in DefaultUsing) + AddUsing(use); + + if (log) + ExplorerCore.Log($"C# Console reset. Using directives:\r\n{Evaluator.GetUsing()}"); } public override void Update() @@ -96,7 +100,6 @@ namespace UnityExplorer.UI.Main.CSConsole UpdateConsole(); AutoCompleter.Update(); - #if CPP Il2CppCoroutine.Process(); #endif @@ -572,11 +575,40 @@ The following helper methods are available: highlightTextInput.supportRichText = true; highlightTextInput.fontSize = fontSize; -#endregion + #endregion -#region COMPILE BUTTON + #region COMPILE BUTTON BAR - var compileBtnObj = UIFactory.CreateButton(Content); + var horozGroupObj = UIFactory.CreateHorizontalGroup(Content, new Color(1, 1, 1, 0)); + var horozGroup = horozGroupObj.GetComponent(); + horozGroup.padding.left = 2; + horozGroup.padding.top = 2; + horozGroup.padding.right = 2; + horozGroup.padding.bottom = 2; + + var resetBtnObj = UIFactory.CreateButton(horozGroupObj); + var resetBtnLayout = resetBtnObj.AddComponent(); + resetBtnLayout.preferredWidth = 80; + resetBtnLayout.flexibleWidth = 0; + resetBtnLayout.minHeight = 45; + resetBtnLayout.flexibleHeight = 0; + var resetButton = resetBtnObj.GetComponent