mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-07 10:03:38 +08:00
Add Reset button to C# Console
This commit is contained in:
parent
8964c48ba0
commit
604c499822
@ -17,7 +17,7 @@ namespace UnityExplorer
|
|||||||
public class ExplorerCore
|
public class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
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 AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ using UnityEngine.UI;
|
|||||||
using UnityExplorer.UI.Reusable;
|
using UnityExplorer.UI.Reusable;
|
||||||
using UnityExplorer.UI.Main.CSConsole;
|
using UnityExplorer.UI.Main.CSConsole;
|
||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
|
using UnityExplorer.Core.Unity;
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnityExplorer.Core.Runtime.Il2Cpp;
|
using UnityExplorer.Core.Runtime.Il2Cpp;
|
||||||
#endif
|
#endif
|
||||||
@ -56,13 +57,10 @@ namespace UnityExplorer.UI.Main.CSConsole
|
|||||||
DummyBehaviour.Setup();
|
DummyBehaviour.Setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ResetConsole();
|
ResetConsole(false);
|
||||||
// Make sure compiler is supported on this platform
|
// Make sure compiler is supported on this platform
|
||||||
Evaluator.Compile("");
|
Evaluator.Compile("");
|
||||||
|
|
||||||
foreach (string use in DefaultUsing)
|
|
||||||
AddUsing(use);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -79,7 +77,7 @@ namespace UnityExplorer.UI.Main.CSConsole
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetConsole()
|
public void ResetConsole(bool log = true)
|
||||||
{
|
{
|
||||||
if (Evaluator != null)
|
if (Evaluator != null)
|
||||||
Evaluator.Dispose();
|
Evaluator.Dispose();
|
||||||
@ -89,6 +87,12 @@ namespace UnityExplorer.UI.Main.CSConsole
|
|||||||
Evaluator = new ScriptEvaluator(new StringWriter(m_evalLogBuilder)) { InteractiveBaseClass = typeof(ScriptInteraction) };
|
Evaluator = new ScriptEvaluator(new StringWriter(m_evalLogBuilder)) { InteractiveBaseClass = typeof(ScriptInteraction) };
|
||||||
|
|
||||||
UsingDirectives = new List<string>();
|
UsingDirectives = new List<string>();
|
||||||
|
|
||||||
|
foreach (string use in DefaultUsing)
|
||||||
|
AddUsing(use);
|
||||||
|
|
||||||
|
if (log)
|
||||||
|
ExplorerCore.Log($"C# Console reset. Using directives:\r\n{Evaluator.GetUsing()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
@ -96,7 +100,6 @@ namespace UnityExplorer.UI.Main.CSConsole
|
|||||||
UpdateConsole();
|
UpdateConsole();
|
||||||
|
|
||||||
AutoCompleter.Update();
|
AutoCompleter.Update();
|
||||||
|
|
||||||
#if CPP
|
#if CPP
|
||||||
Il2CppCoroutine.Process();
|
Il2CppCoroutine.Process();
|
||||||
#endif
|
#endif
|
||||||
@ -572,11 +575,40 @@ The following helper methods are available:
|
|||||||
highlightTextInput.supportRichText = true;
|
highlightTextInput.supportRichText = true;
|
||||||
highlightTextInput.fontSize = fontSize;
|
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<HorizontalLayoutGroup>();
|
||||||
|
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<LayoutElement>();
|
||||||
|
resetBtnLayout.preferredWidth = 80;
|
||||||
|
resetBtnLayout.flexibleWidth = 0;
|
||||||
|
resetBtnLayout.minHeight = 45;
|
||||||
|
resetBtnLayout.flexibleHeight = 0;
|
||||||
|
var resetButton = resetBtnObj.GetComponent<Button>();
|
||||||
|
var resetBtnColors = resetButton.colors;
|
||||||
|
resetBtnColors.normalColor = "666666".ToColor();
|
||||||
|
resetButton.colors = resetBtnColors;
|
||||||
|
var resetBtnText = resetBtnObj.GetComponentInChildren<Text>();
|
||||||
|
resetBtnText.text = "Reset";
|
||||||
|
resetBtnText.fontSize = 18;
|
||||||
|
resetBtnText.color = Color.white;
|
||||||
|
|
||||||
|
// Set compile button callback now that we have the Input Field reference
|
||||||
|
resetButton.onClick.AddListener(ResetCallback);
|
||||||
|
void ResetCallback()
|
||||||
|
{
|
||||||
|
ResetConsole();
|
||||||
|
}
|
||||||
|
|
||||||
|
var compileBtnObj = UIFactory.CreateButton(horozGroupObj);
|
||||||
var compileBtnLayout = compileBtnObj.AddComponent<LayoutElement>();
|
var compileBtnLayout = compileBtnObj.AddComponent<LayoutElement>();
|
||||||
compileBtnLayout.preferredWidth = 80;
|
compileBtnLayout.preferredWidth = 80;
|
||||||
compileBtnLayout.flexibleWidth = 0;
|
compileBtnLayout.flexibleWidth = 0;
|
||||||
@ -601,7 +633,7 @@ The following helper methods are available:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//mainTextInput.supportRichText = false;
|
//mainTextInput.supportRichText = false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user