@@ -27,6 +27,7 @@ public static class ConsoleController
2727
2828 private static HashSet < string > usingDirectives ;
2929 private static StringBuilder evaluatorOutput ;
30+ private static StringWriter evaluatorStringWriter ;
3031
3132 public static CSConsolePanel Panel => UIManager . GetPanel < CSConsolePanel > ( UIManager . Panels . CSConsole ) ;
3233 public static InputFieldRef Input => Panel . Input ;
@@ -46,6 +47,7 @@ public static class ConsoleController
4647 "System" ,
4748 "System.Linq" ,
4849 "System.Text" ,
50+ "System.Collections" ,
4951 "System.Collections.Generic" ,
5052 "UnityEngine" ,
5153#if CPP
@@ -130,6 +132,12 @@ private static void OnToggleSuggestions(bool value)
130132
131133 #region Evaluating
132134
135+ private static void GenerateTextWriter ( )
136+ {
137+ evaluatorOutput = new StringBuilder ( ) ;
138+ evaluatorStringWriter = new StringWriter ( evaluatorOutput ) ;
139+ }
140+
133141 public static void ResetConsole ( ) => ResetConsole ( true ) ;
134142
135143 public static void ResetConsole ( bool logSuccess = true )
@@ -140,8 +148,8 @@ public static void ResetConsole(bool logSuccess = true)
140148 if ( Evaluator != null )
141149 Evaluator . Dispose ( ) ;
142150
143- evaluatorOutput = new StringBuilder ( ) ;
144- Evaluator = new ScriptEvaluator ( new StringWriter ( evaluatorOutput ) )
151+ GenerateTextWriter ( ) ;
152+ Evaluator = new ScriptEvaluator ( evaluatorStringWriter )
145153 {
146154 InteractiveBaseClass = typeof ( ScriptInteraction )
147155 } ;
@@ -176,6 +184,12 @@ public static void Evaluate(string input, bool supressLog = false)
176184 if ( SRENotSupported )
177185 return ;
178186
187+ if ( evaluatorStringWriter == null || evaluatorOutput == null )
188+ {
189+ GenerateTextWriter ( ) ;
190+ Evaluator . _textWriter = evaluatorStringWriter ;
191+ }
192+
179193 try
180194 {
181195 // Compile the code. If it returned a CompiledMethod, it is REPL.
0 commit comments