├── .gitignore
├── Assets
├── LICENSE.txt
├── LICENSE.txt.meta
├── UCompile.meta
└── UCompile
│ ├── Core.meta
│ ├── Core
│ ├── Plugins.meta
│ ├── Plugins
│ │ ├── LICENSE.txt
│ │ ├── LICENSE.txt.meta
│ │ └── mcs.dll.meta
│ ├── ScriptEngine.meta
│ └── ScriptEngine
│ │ ├── CSScriptEngine.cs
│ │ ├── CSScriptEngine.cs.meta
│ │ ├── CSScriptEngineInterfaces.cs
│ │ ├── CSScriptEngineInterfaces.cs.meta
│ │ ├── CSScriptEngineRemote.cs
│ │ ├── CSScriptEngineRemote.cs.meta
│ │ ├── Logger.cs
│ │ ├── Logger.cs.meta
│ │ ├── MonoEvaluator.cs
│ │ └── MonoEvaluator.cs.meta
│ ├── Documentation.meta
│ ├── Documentation
│ ├── README.md - Grip.html
│ ├── README.md - Grip.html.meta
│ ├── README.md - Grip_files.meta
│ └── README.md - Grip_files
│ │ ├── CompilationScheme.png
│ │ ├── CompilationScheme.png.meta
│ │ ├── ExampleProjectGUI.png
│ │ ├── ExampleProjectGUI.png.meta
│ │ ├── UcompileStructureScheme.png
│ │ ├── UcompileStructureScheme.png.meta
│ │ ├── frameworks-b1642e37b45963af25ee113eaec46c25df28655ab893baf240e31a7dd0a215ea.css
│ │ ├── frameworks-b1642e37b45963af25ee113eaec46c25df28655ab893baf240e31a7dd0a215ea.css.meta
│ │ ├── github-e9228d764bc8fd6a49739e9a2e155477e49f87e735d550f10ae45b3cdb394a95.css
│ │ ├── github-e9228d764bc8fd6a49739e9a2e155477e49f87e735d550f10ae45b3cdb394a95.css.meta
│ │ ├── logo github banner.png
│ │ ├── logo github banner.png.meta
│ │ ├── site-3b27741f2e22b48854ecee715112d86949a7c9e4e502f41739c4578cc65283da.css
│ │ ├── site-3b27741f2e22b48854ecee715112d86949a7c9e4e502f41739c4578cc65283da.css.meta
│ │ ├── system-fonts-b4cd5a28f837260371d5a61872bda2262ec244fc0c92bc9243fec8d26d246840.css
│ │ └── system-fonts-b4cd5a28f837260371d5a61872bda2262ec244fc0c92bc9243fec8d26d246840.css.meta
│ ├── ExampleProject.meta
│ ├── ExampleProject
│ ├── CheatSheet.meta
│ ├── CheatSheet
│ │ ├── CheatSheet.cs
│ │ ├── CheatSheet.cs.meta
│ │ ├── CheatSheetScene.unity
│ │ └── CheatSheetScene.unity.meta
│ ├── ExampleCode.txt
│ ├── ExampleCode.txt.meta
│ ├── Prefabs.meta
│ ├── Prefabs
│ │ ├── GUI.meta
│ │ └── GUI
│ │ │ ├── Canvas.prefab
│ │ │ ├── Canvas.prefab.meta
│ │ │ ├── ClassNameButton.prefab
│ │ │ ├── ClassNameButton.prefab.meta
│ │ │ ├── EventManager.prefab
│ │ │ └── EventManager.prefab.meta
│ ├── Scenes.meta
│ ├── Scenes
│ │ ├── Main.unity
│ │ └── Main.unity.meta
│ ├── Scripts.meta
│ └── Scripts
│ │ ├── GUI.meta
│ │ ├── GUI
│ │ ├── CSScriptInterpreterView.cs
│ │ ├── CSScriptInterpreterView.cs.meta
│ │ ├── ClassNameButton.cs
│ │ ├── ClassNameButton.cs.meta
│ │ ├── ConsoleWindowPanel.cs
│ │ ├── ConsoleWindowPanel.cs.meta
│ │ ├── EditMBPanel.cs
│ │ ├── EditMBPanel.cs.meta
│ │ ├── TypeEditorWindowControl.cs
│ │ ├── TypeEditorWindowControl.cs.meta
│ │ ├── UtilityPanelControl.cs
│ │ └── UtilityPanelControl.cs.meta
│ │ ├── Managers.meta
│ │ ├── Managers
│ │ ├── EventManager.cs
│ │ ├── EventManager.cs.meta
│ │ ├── Events.cs
│ │ └── Events.cs.meta
│ │ ├── Utility.meta
│ │ ├── Utility
│ │ ├── GhostFreeRoamCamera.cs
│ │ └── GhostFreeRoamCamera.cs.meta
│ │ ├── WhitelistAPI.meta
│ │ └── WhitelistAPI
│ │ ├── WhitelistAPI.cs
│ │ └── WhitelistAPI.cs.meta
│ ├── Tests.meta
│ └── Tests
│ ├── IntegrationTests.meta
│ ├── IntegrationTests
│ ├── CSScriptEngineRemoteTests.meta
│ ├── CSScriptEngineRemoteTests
│ │ ├── CSScriptEngineRemoteIntegrationTests.unity
│ │ ├── CSScriptEngineRemoteIntegrationTests.unity.meta
│ │ ├── CSScriptEngineRemoteTests.cs
│ │ └── CSScriptEngineRemoteTests.cs.meta
│ ├── CSScriptEngineTests.meta
│ └── CSScriptEngineTests
│ │ ├── CSScriptEngineIntTests.cs
│ │ ├── CSScriptEngineIntTests.cs.meta
│ │ ├── CSScriptEngineIntegrationTests.unity
│ │ ├── CSScriptEngineIntegrationTests.unity.meta
│ │ ├── CSScriptEngineTests.prefab
│ │ ├── CSScriptEngineTests.prefab.meta
│ │ ├── CSScriptEngineUsingsSystemTest.cs
│ │ ├── CSScriptEngineUsingsSystemTest.cs.meta
│ │ ├── CSScriptEngineUsingsTests.prefab
│ │ └── CSScriptEngineUsingsTests.prefab.meta
│ ├── UnitTests.rar
│ └── UnitTests.rar.meta
├── DocumentationMisc
├── Big logo.png
├── CompilationScheme.png
├── ExampleProjectGUI.png
├── UcompileStructureScheme.png
└── logo github banner.png
├── ProjectSettings
├── AudioManager.asset
├── ClusterInputManager.asset
├── DynamicsManager.asset
├── EditorBuildSettings.asset
├── EditorSettings.asset
├── GraphicsSettings.asset
├── InputManager.asset
├── NavMeshAreas.asset
├── NetworkManager.asset
├── Physics2DSettings.asset
├── ProjectSettings.asset
├── ProjectVersion.txt
├── QualitySettings.asset
├── TagManager.asset
├── TimeManager.asset
├── UnityAdsSettings.asset
└── UnityConnectSettings.asset
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | *.sln
2 | *.csproj
3 | /Library
4 | /Build
5 | /obj
6 | /Temp
7 |
8 | /Assets/AssetStoreTools
9 | /Assets/AssetStoreTools.meta
10 |
11 | #ignoring pidb, they are just code completion caching data according to:
12 | # http://stackoverflow.com/questions/1022111/what-are-monodevelops-pidb-files
13 | *.pidb
14 |
15 | *.userprefs
16 |
17 | !/Assets/Core/Plugins/mcs.dll
18 |
--------------------------------------------------------------------------------
/Assets/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Ilya Bykov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Assets/LICENSE.txt.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0407d6ca1bfc90345874880a98a6fa13
3 | timeCreated: 1467540624
4 | licenseType: Free
5 | TextScriptImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 73fd1735cc2ac794ea6d23a8873ae7de
3 | folderAsset: yes
4 | timeCreated: 1468854653
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 019549af919be5744aee34edcda35831
3 | folderAsset: yes
4 | timeCreated: 1460825003
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/Plugins.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 69208331d0a5cec4c94efd0eb38f30bb
3 | folderAsset: yes
4 | timeCreated: 1460824292
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/Plugins/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2001, 2002, 2003 Ximian, Inc and the individuals listed
2 | on the ChangeLog entries.
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Assets/UCompile/Core/Plugins/LICENSE.txt.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3941cffac9a80174ab6ee68a61dbfa82
3 | timeCreated: 1467539884
4 | licenseType: Free
5 | TextScriptImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/Plugins/mcs.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6f62bcd31dcb9724586ec575e3acede1
3 | timeCreated: 1461259946
4 | licenseType: Free
5 | PluginImporter:
6 | serializedVersion: 1
7 | iconMap: {}
8 | executionOrder: {}
9 | isPreloaded: 0
10 | platformData:
11 | Any:
12 | enabled: 1
13 | settings: {}
14 | Editor:
15 | enabled: 0
16 | settings:
17 | CPU: AnyCPU
18 | DefaultValueInitialized: true
19 | OS: AnyOS
20 | Linux:
21 | enabled: 0
22 | settings:
23 | CPU: x86
24 | Linux64:
25 | enabled: 0
26 | settings:
27 | CPU: x86_64
28 | LinuxUniversal:
29 | enabled: 0
30 | settings:
31 | CPU: None
32 | OSXIntel:
33 | enabled: 0
34 | settings:
35 | CPU: AnyCPU
36 | OSXIntel64:
37 | enabled: 0
38 | settings:
39 | CPU: AnyCPU
40 | OSXUniversal:
41 | enabled: 0
42 | settings:
43 | CPU: None
44 | Win:
45 | enabled: 0
46 | settings:
47 | CPU: None
48 | Win64:
49 | enabled: 0
50 | settings:
51 | CPU: None
52 | WindowsStoreApps:
53 | enabled: 0
54 | settings:
55 | CPU: AnyCPU
56 | userData:
57 | assetBundleName:
58 | assetBundleVariant:
59 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f4a0e4ff7c0d2a043af7531cdefd0468
3 | folderAsset: yes
4 | timeCreated: 1460823700
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/CSScriptEngine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Text.RegularExpressions;
6 | using System.Collections;
7 | using System.Linq;
8 | using System.IO;
9 |
10 | namespace UCompile
11 | {
12 |
13 | ///
14 | /// This class is a wrapper around MonoEvaluator.
15 | ///
16 | public class CompilationUnit
17 | {
18 | ICompilationSystem _eval = null;
19 |
20 | Assembly _lastAsm = null;
21 |
22 | Dictionary _typeCodeStore = new Dictionary();
23 | public Dictionary TypeCodeStore { get { return _typeCodeStore; } }
24 |
25 | public List AllReferencedAssemblies {get { return _eval.AllReferencedAssemblies; }}
26 |
27 | StringBuilder _allTypesCode = new StringBuilder();
28 |
29 | public Action OnCompilationSucceededDelegate;
30 | public Action OnCompilationFailedDelegate;
31 |
32 | //Flag used to determine, if compilation returned error,
33 | //which delegate to use: OnCompilationSucceededDelegate or OnCompilationFailedDelegate
34 | bool _lastCompilationFailed = false;
35 |
36 | public CompilerOutput LastCompilerOutput { get { return _eval.CompilationOutput; } }
37 |
38 | //Push dependency up the hierarchy
39 | public CompilationUnit(ICompilationSystem compilationProvider)
40 | {
41 | _eval = compilationProvider;
42 | }
43 |
44 | //Adds type code to the _typeCodeStore, marked with specific typeID
45 | public void AddType(string typeID,string code)
46 | {
47 | if (_typeCodeStore.ContainsKey(typeID))
48 | _typeCodeStore[typeID] = code;
49 | else
50 | _typeCodeStore.Add(typeID, code);
51 | }
52 |
53 | public void RemoveType(string typeID)
54 | {
55 | if (_typeCodeStore.ContainsKey(typeID))
56 | _typeCodeStore.Remove(typeID);
57 | }
58 |
59 | //Takes all types in _typeCodeStore and compiles them into assembly
60 | public Assembly CompileTypesIntoAssembly()
61 | {
62 | _allTypesCode.Length = 0;
63 | _allTypesCode.Capacity = 0;
64 |
65 | string[] temp = new string[_typeCodeStore.Count];
66 | _typeCodeStore.Values.CopyTo(temp,0);
67 |
68 | for (int i = 0;i < _typeCodeStore.Count;i++)
69 | {
70 | _allTypesCode.Append(temp[i]);
71 | }
72 |
73 | HandleCompilationErrors(()=>_lastAsm = _eval.CompileCode(_allTypesCode.ToString()));
74 |
75 | return _lastAsm;
76 | }
77 |
78 | public void Run(string code)
79 | {
80 | _eval.Run(code);
81 | }
82 |
83 | public void ReferenceAssemblies(params Assembly[] assemblies)
84 | {
85 | _eval.ReferenceAssemblies(assemblies);
86 | }
87 |
88 | public void HandleCompilationErrors(Action compilationAction)
89 | {
90 |
91 | try
92 | {
93 | compilationAction();
94 | }
95 | catch (CompilerException ex)
96 | {
97 | if (OnCompilationFailedDelegate != null)
98 | OnCompilationFailedDelegate(new CompilerOutput(ex));
99 |
100 | _lastCompilationFailed = true;
101 |
102 | //if there was exception, we need to set _lastAsm to null here
103 | _lastAsm = null;
104 | }
105 | finally
106 | {
107 | //OnCompilationSucceededDelegate only fires, if last compilation succeeded without errors
108 | //so, _lastCompilationflag must be set to false
109 | if (!_lastCompilationFailed && OnCompilationSucceededDelegate != null)
110 | {
111 | OnCompilationSucceededDelegate(_eval.CompilationOutput);
112 | }
113 |
114 | //In case there were errors, we'll reset _lastCompilationFailed flag to false
115 | _lastCompilationFailed = false;
116 | }
117 | }
118 |
119 | public void Reset()
120 | {
121 | _typeCodeStore.Clear();
122 | _eval.Reset();
123 | }
124 |
125 | public void SoftReset()
126 | {
127 | _eval.SoftReset();
128 | }
129 | }
130 | //TODO: every time recompilation occurs, all types added will be compiled into the single assembly
131 | //so when 1 type changes, we need to recompile all dynamic types code. It's okay for small quantities of types
132 | //but probably it's worth it, to add system, that compiles each type into separate assembly.
133 | //TODO: add file compilation, right now there is only "in memory" compilation of code strings.
134 | //TODO: implement better logging
135 | //TODO: add ability to add and remove assembly references, without AddUsing().
136 | //TODO: need to handle situation with memory leak because of the infinite amount of loading assemblies.
137 | //TODO: get rid of Linq usage.
138 | ///
139 | /// This class essentially takes C# code as a string, and compiles
140 | /// it into assembly, so this code becomes a part of the main codebase.
141 | ///
142 | public class CSScriptEngine
143 | {
144 |
145 | CompilationUnit _unit = null;
146 |
147 | List _allUsings = new List();
148 | public List AllUsings { get { return _allUsings; } }
149 |
150 | public List AllReferencedAssemblies { get { return _unit.AllReferencedAssemblies; } }
151 |
152 | Dictionary _allUsingsAndRelatedAssemblies = new Dictionary();
153 |
154 | Assembly[] _allAppDomainAssemblies;
155 |
156 | Assembly _lastCompiledAssembly = null;
157 |
158 | Regex _usingsDerictivesRegEx = new Regex(@"^(\s*using\s*[A-Z,a-z]+(\.[A-z,a-z]+)*\s*;\s*)+$");
159 |
160 |
161 | string _template =
162 | @"public class Script : IScript{
163 | $METHODS$
164 | }";
165 |
166 | string _allMethods =
167 | @"public void Execute()
168 | {
169 | $BODY$
170 | }
171 | public System.Collections.IEnumerable Coroutine()
172 | {
173 | $CBODY$
174 | }";
175 |
176 | string _lastCompiledCode = "";
177 | string _lastCompiledCoroutine = "yield return null;";
178 |
179 | ///
180 | /// Creates new instance of CSScriptEngine with MonoEvaluator as default ICompilationSystem.
181 | ///
182 | public CSScriptEngine()
183 | {
184 | _unit = new CompilationUnit(new MonoEvaluator());
185 |
186 | _allAppDomainAssemblies = AppDomain.CurrentDomain.GetAssemblies();
187 |
188 | //We need to reference executing assembly, because it contains IScript interface, which
189 | //is used in CompileCode() as wrapper class.
190 | _unit.ReferenceAssemblies(Assembly.GetExecutingAssembly());
191 | }
192 |
193 | ///
194 | /// Creates new instance of CSScriptEngine with provided ICompilationSystem under the hood.
195 | ///
196 | /// Implementation of ICompilationSystem interface.
197 | public CSScriptEngine(ICompilationSystem compilationProvider)
198 | {
199 | _unit = new CompilationUnit(compilationProvider);
200 |
201 | _allAppDomainAssemblies = AppDomain.CurrentDomain.GetAssemblies();
202 |
203 | //We need to reference executing assembly, because it contains IScript interface, which
204 | //is used in CompileCode as wrapper class.
205 | _unit.ReferenceAssemblies(Assembly.GetExecutingAssembly());
206 | }
207 |
208 | public Assembly CompileCurrentTypesIntoAssembly()
209 | {
210 | if (_lastCompiledAssembly == null && _unit.TypeCodeStore.Count != 0)
211 | {
212 | return _lastCompiledAssembly = _unit.CompileTypesIntoAssembly();
213 | }
214 | else return _lastCompiledAssembly;
215 |
216 | }
217 |
218 | ///
219 | /// Returns CompilerOutput, that contains errors
220 | /// and warnings from the last compilation.
221 | ///
222 | ///
223 | public CompilerOutput GetLastCompilerOutput()
224 | {
225 | return _unit.LastCompilerOutput;
226 | }
227 |
228 | ///
229 | /// Nullifies all added usings, referenced assemblies and last compiled assembly
230 | ///
231 | public void Reset()
232 | {
233 | ResetCompilationUnit();
234 |
235 | _allUsings = new List();
236 | _allUsingsAndRelatedAssemblies = new Dictionary();
237 |
238 | _lastCompiledAssembly = null;
239 | }
240 |
241 | //Resets compilation unit exclusively.
242 | void ResetCompilationUnit()
243 | {
244 | _unit.Reset();
245 | _unit.ReferenceAssemblies(Assembly.GetExecutingAssembly());
246 | }
247 |
248 | //Resets CompilationUnit, then declares usings again
249 | void UpdateUsings()
250 | {
251 | _unit.Run(string.Join("", _allUsings.ToArray()));
252 | }
253 |
254 | Assembly GetAssemblyByNamespace(string namespaceName)
255 | {
256 | if (Assembly.GetExecutingAssembly().GetTypes().Any((x) => x.Namespace == namespaceName))
257 | return Assembly.GetExecutingAssembly();
258 | else
259 | {
260 | try
261 | {
262 | //Get all namespace hierarchy
263 | string[] allNamespacesNames = namespaceName.Split('.');
264 |
265 | if (allNamespacesNames.Length > 1)
266 | {
267 | Assembly[] possibleAssemblies = _allAppDomainAssemblies.Where((x) => x.GetName().Name.Split('.')[0] == allNamespacesNames[0]).ToArray();
268 |
269 | //If we can't find assemblies with assembly name in namespaceName, then
270 | //it's probably because this assembly name is wrong
271 | if (possibleAssemblies.Length == 0)
272 | return null;
273 |
274 | StringBuilder tempSB = new StringBuilder(namespaceName);
275 |
276 | for (int i = allNamespacesNames.Length - 1; i >= 0; i--)
277 | {
278 | for(int j = 0; j < possibleAssemblies.Length;j++)
279 | {
280 | if(possibleAssemblies[j].GetName().Name == tempSB.ToString())
281 | return Assembly.Load(new AssemblyName(tempSB.ToString()));
282 | }
283 |
284 | tempSB.Remove(tempSB.Length - allNamespacesNames[i].Length - 1, allNamespacesNames[i].Length + 1);
285 | }
286 |
287 | return null;
288 | }
289 |
290 | return Assembly.Load(new AssemblyName(namespaceName));
291 | }
292 | catch(Exception ex)
293 | {
294 | if (ex is FileNotFoundException)
295 | return null;
296 | else
297 | throw ex;
298 | }
299 | }
300 | }
301 | ///
302 | /// Adds using directives, so it applies to all code, that is to be dynamically compiled.
303 | /// Also references assemblies, which these usings refer to. Namespaces hierarchy must be fully described, for example:
304 | ///
305 | /// "using System.CodeDOM; using UnityEngine.UI; using UnityEngine.Advertisements;"
306 | ///
307 | ///
308 | /// String with all usings in it, for example:
309 | /// "using UnityEngine; using System.CodeDOM; using AssemblyName.NamespaceName;"
310 | public void AddUsings(string usings)
311 | {
312 | if (usings != null && _usingsDerictivesRegEx.IsMatch(usings))
313 | {
314 | string[] temp = usings.Split(';');
315 |
316 | for (int i = 0; i < temp.Length - 1; i++)
317 | {
318 | string currentUsing = temp[i].TrimStart() + ';';
319 |
320 | //let's get rid of empty string that gets added to array, because of the last
321 | //';'
322 | temp[temp.Length - 1] = null;
323 |
324 | if (!_allUsings.Contains(currentUsing))
325 | {
326 | try
327 | {
328 | //strip away "using " so only the assembly name is left
329 | Assembly usingsAssembly = GetAssemblyByNamespace(temp[i].Substring(6).TrimStart());
330 |
331 | //if Assembly was found
332 | if (usingsAssembly != null)
333 | {
334 | _allUsingsAndRelatedAssemblies.Add(currentUsing, usingsAssembly);
335 | _allUsings.Add(currentUsing);
336 | temp[i] = currentUsing;
337 | }
338 | else
339 | {
340 | //if we can't find this using's namespace among currently loaded assemblies, then it's invalid
341 | throw new ArgumentException("The namespace in one of using derictives is not valid, or assembly containing it is not loaded to current AppDomain");
342 | }
343 | }
344 | catch (Exception ex)
345 | {
346 | //If exception isn't connected with invalid input, then rethrow it
347 | throw ex;
348 | }
349 | }
350 | else
351 | {
352 | //if using was already added, delete it from temp array
353 | temp[i] = null;
354 | }
355 | }
356 |
357 | StringBuilder tempSB = new StringBuilder();
358 |
359 | List assembliesToReference = new List();
360 |
361 | for (int i = 0; i < temp.Length - 1; i++)
362 | {
363 | if (temp[i] != null)
364 | {
365 | tempSB.Append(temp[i]);
366 | assembliesToReference.Add(_allUsingsAndRelatedAssemblies[temp[i]]);
367 | }
368 | }
369 |
370 | _unit.ReferenceAssemblies(assembliesToReference.ToArray());
371 |
372 | try {
373 | _unit.Run(tempSB.ToString());
374 | }
375 | catch(Exception ex)
376 | {
377 | //it should be unlikely, but if Run threw exception, we will reset all changes,
378 | //and rethrow this exception
379 | ResetCompilationUnit();
380 | for (int i = 0; i < temp.Length - 1; i++)
381 | {
382 | if (temp[i] != null)
383 | {
384 | _allUsings.Remove(temp[i]);
385 | _allUsingsAndRelatedAssemblies.Remove(temp[i]);
386 | }
387 | }
388 |
389 | StringBuilder sB = new StringBuilder();
390 |
391 | foreach (string usng in _allUsings)
392 | sB.Append(usng);
393 |
394 | _unit.ReferenceAssemblies(_allUsingsAndRelatedAssemblies.Values.ToArray());
395 | _unit.Run(sB.ToString());
396 |
397 | throw ex;
398 | }
399 | }
400 | else
401 | throw new ArgumentException("Invalid argument");
402 | }
403 |
404 | ///
405 | /// Removes usings already referenced in system. Also removes related assemblies and thier references.
406 | ///
407 | /// Usings to remove
408 | public void RemoveUsings(string usings)
409 | {
410 | if (usings != null && _usingsDerictivesRegEx.IsMatch(usings) && _allUsings.Count != 0)
411 | {
412 |
413 | string[] temp = usings.Split(';');
414 |
415 | //Check if usings are already exists in _allUsings list
416 | for (int i = 0; i < temp.Length - 1; i++)
417 | if (!_allUsings.Contains(temp[i].TrimStart() + ';'))
418 | throw new ArgumentException("Can't find using directive");
419 |
420 | for (int i = 0; i < temp.Length - 1; i++)
421 | {
422 | string currentUsing = temp[i] + ';';
423 |
424 | _allUsings.Remove(currentUsing);
425 | _allUsingsAndRelatedAssemblies.Remove(currentUsing);
426 |
427 | temp[i] = currentUsing;
428 | }
429 | ResetCompilationUnit();
430 |
431 | if (_allUsings.Count != 0)
432 | {
433 |
434 | StringBuilder tempSB = new StringBuilder();
435 |
436 | for (int i = 0; i < _allUsings.Count; i++)
437 | tempSB.Append(_allUsings[i]);
438 | _unit.ReferenceAssemblies(_allUsingsAndRelatedAssemblies.Values.ToArray());
439 | _unit.Run(tempSB.ToString());
440 | }
441 | }
442 | else
443 | throw new ArgumentException("Invalid argument");
444 | }
445 |
446 | ///
447 | /// Compiles string with C# code without class declaration. For example:
448 | ///
449 | /// CSScriptEngine engine = new CSScriptEngine();
450 | /// IScript result = engine.CompileCode(@"UnityEngine.Debug.Log(""Hello!"");");
451 | /// result.Execute();
452 | ///
453 | ///
454 | /// String with C# code
455 | /// IScript object, encapsulating the code, or null if compilation failed
456 | public IScript CompileCode(string code = "")
457 | {
458 | if (code != "")
459 | _lastCompiledCode = code;
460 | else
461 | return null;
462 |
463 | return CompileFinalSource(_lastCompiledCode, false);
464 |
465 | }
466 |
467 | ///
468 | /// Compiles string with C# coroutine code without class declaration. For example:
469 | ///
470 | /// CSScriptEngine engine = new CSScriptEngine();
471 | /// IEnumerable result = engine.CompileCoroutine(@"yield return new UnityEngine.WaitForSeconds(1f);UnityEngine.Debug.Log(""Hello!"");");
472 | /// StartCoroutine(result.GetEnumerator());
473 | ///
474 | ///
475 | /// String with coroutine code
476 | /// IScript object, encapsulating the code, or null if compilation failed
477 | public IEnumerable CompileCoroutine(string coroutineCode = "")
478 | {
479 | if (coroutineCode != "")
480 | _lastCompiledCoroutine = coroutineCode;
481 | else
482 | return null;
483 |
484 | IScript result = CompileFinalSource(_lastCompiledCoroutine, true);
485 |
486 | return result == null ? null : result.Coroutine();
487 | }
488 |
489 | //TODO: get rid of isCoroutine flag argument, maybe implement isCoroutine function
490 | ///
491 | /// Prepares classless code for compilation by wrapping it into Script : IScript class,
492 | /// then compiles it into assembly and returns Script object in form of IScript interface.
493 | ///
494 | ///
495 | ///
496 | /// IScript object, encapsulating the code, or null if compilation failed
497 | IScript CompileFinalSource(string finalMethodSource, bool isCoroutine)
498 | {
499 | StringBuilder finalSource = new StringBuilder(_allMethods);
500 |
501 | if (!isCoroutine)
502 | finalSource = finalSource.Replace("$BODY$", finalMethodSource).Replace("$CBODY$", _lastCompiledCoroutine);
503 | else
504 | finalSource = finalSource.Replace("$CBODY$", finalMethodSource).Replace("$BODY$", _lastCompiledCode);
505 |
506 | _unit.AddType("ScriptType", _template.Replace("$METHODS$", finalSource.ToString()));
507 |
508 | _lastCompiledAssembly = _unit.CompileTypesIntoAssembly();
509 |
510 | _unit.RemoveType("ScriptType");//We need to remove ScriptType, so it won't clash with other types on compilation
511 |
512 | //Reset lastCompiled containers, so coroutine and plain method code are not going to clash on compilation
513 | if (isCoroutine)
514 | _lastCompiledCoroutine = "yield return null;";
515 | else
516 | _lastCompiledCode = "";
517 |
518 | if (_lastCompiledAssembly == null)
519 | {
520 | UpdateUsings();
521 | return null;
522 | }
523 | else return (IScript)Activator.CreateInstance(_lastCompiledAssembly.GetType("Script"));
524 | }
525 |
526 | ///
527 | /// Compiles string with class code and returns Type of this class. Compiled class is added to Assembly
528 | /// with all dynamically compiled classes, and can be used by them.
529 | /// Don't use usings directives in class code, for adding usings use AddUsings(string usings).
530 | /// For example:
531 | ///
532 | /// CSScriptEngine engine = new CSScriptEngine();
533 | ///
534 | /// engine.AddUsings("using UnityEngine;");
535 | ///
536 | /// string code = @"public class SomeClass
537 | /// {
538 | /// public void Print() { Debug.Log(""Hello!""); }
539 | /// }";
540 | ///
541 | /// engine.CompileType("SomeClass", code);
542 | ///
543 | /// engine.CompileCode(@"SomeClass sc = new SomeClass(); sc.Print();").Execute();
544 | ///
545 | ///
546 | /// Unique ID of the type to compile
547 | /// String with type code
548 | /// Type of the class to compile. null, if compilation failed
549 | public Type CompileType(string typeID, string code)
550 | {
551 | //if type we are trying to compile already exists in _unit.TypeCodeStore
552 | //then we're editing existing type, and not adding new one.
553 | //In this case we need to SoftReset _unit, to get rid of a reference to previously compiled type
554 | //with the same ID, so it becomes inaccessible on further compilations of code or types.
555 | if (_unit.TypeCodeStore.ContainsKey(typeID))
556 | {
557 | _unit.SoftReset();
558 | UpdateUsings();
559 | }
560 |
561 | _unit.AddType(typeID, code);
562 |
563 | _lastCompiledAssembly = _unit.CompileTypesIntoAssembly();
564 |
565 | if (_lastCompiledAssembly == null)
566 | {
567 | UpdateUsings();
568 | _unit.RemoveType(typeID);
569 | return null;
570 | }
571 |
572 | return _lastCompiledAssembly.GetType(typeID);
573 | }
574 |
575 | ///
576 | /// Removes type from system, so it can't be used in dynamically compiled code.
577 | ///
578 | /// Unique IDs of the types to remove
579 | public void RemoveTypes(params string[] typeIDs)
580 | {
581 | for(int i = 0; i < typeIDs.Length;i++)
582 | _unit.RemoveType(typeIDs[i]);
583 |
584 | _unit.SoftReset();
585 | UpdateUsings();
586 |
587 | }
588 |
589 | public void AddOnCompilationSucceededHandler(Action onCompilationSucceededHandler)
590 | {
591 | _unit.OnCompilationSucceededDelegate += onCompilationSucceededHandler;
592 | }
593 |
594 | public void RemoveOnCompilationSucceededHandler(Action onCompilationSucceededHandler)
595 | {
596 | _unit.OnCompilationSucceededDelegate -= onCompilationSucceededHandler;
597 | }
598 |
599 | public void AddOnCompilationFailedHandler(Action onCompilationFailedHandler)
600 | {
601 | _unit.OnCompilationFailedDelegate += onCompilationFailedHandler;
602 | }
603 |
604 | public void RemoveOnCompilationFailedHandler(Action onCompilationFailedHandler)
605 | {
606 | _unit.OnCompilationFailedDelegate -= onCompilationFailedHandler;
607 | }
608 | }
609 | }
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/CSScriptEngine.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e82edb844407ada45a8dc8d2d9622c1a
3 | timeCreated: 1460824746
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/CSScriptEngineInterfaces.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | ///
4 | /// Interface for script object defined globally.
5 | ///
6 | public interface IScript
7 | {
8 | void Execute();
9 | IEnumerable Coroutine();
10 | }
11 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/CSScriptEngineInterfaces.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c61d5c247d2a3c74eb6ca2eba7da7763
3 | timeCreated: 1460824799
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/CSScriptEngineRemote.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Collections.Generic;
4 | using UnityEngine;
5 | using System.Collections;
6 | using System.IO;
7 |
8 | namespace UCompile
9 | {
10 | ///
11 | /// Helper class, that will perform operations on assemblies
12 | /// in remote AppDomain
13 | ///
14 | public class RemoteExecutor : MarshalByRefObject {
15 |
16 | CSScriptEngine _engine = null;
17 |
18 | IScript _lastCompiledScript = null;
19 |
20 | //All initializations should be here
21 | public void Initialize()
22 | {
23 | _engine = new CSScriptEngine();
24 | }
25 |
26 | //We'll use this method to clear everything we need to be cleared
27 | public void Dispose()
28 | {
29 | }
30 |
31 | public void AddUsings(string usings)
32 | {
33 | _engine.AddUsings(usings);
34 | }
35 |
36 | public void RemoveUsings(string usings)
37 | {
38 | _engine.RemoveUsings(usings);
39 | }
40 |
41 | public CompilerOutput CompileCode(string code)
42 | {
43 | _lastCompiledScript = _engine.CompileCode(code);
44 | return _engine.GetLastCompilerOutput();
45 | }
46 |
47 | public void ExecuteLastCompiledCode()
48 | {
49 | if (_lastCompiledScript != null)
50 | {
51 | _lastCompiledScript.Execute();
52 | }
53 | }
54 |
55 | public CompilerOutput CompileType(string id, string code)
56 | {
57 | _engine.CompileType(id, code);
58 | return _engine.GetLastCompilerOutput();
59 | }
60 |
61 | public void RemoveTypes(params string[] ids)
62 | {
63 | _engine.RemoveTypes(ids);
64 | }
65 |
66 | public void Reset()
67 | {
68 | _engine.Reset();
69 | }
70 |
71 | //This is needed to prevent LifetimeService object creation
72 | //and thus infinite lifetime is granted for the MarshalByRefObject
73 | //Probably should implement lifetime management via ClientSponsor
74 | //to exclude memory leak risk?
75 | public override object InitializeLifetimeService()
76 | {
77 | return null;
78 | }
79 |
80 | #region DynamicMonoBehaviourSystem
81 | //-----------------------------------------------------------------------------------------------------------------
82 | //TODO: work in progress on this one
83 | //Here goes all the DynamicMonoBehaviourSystemRemote functionality
84 | //It is an attempt to work around the bug in Unity, that causes MonoBehaviours Update(), and some other messages
85 | //to execute in Unity Child Domain, even though This MonoBehaviour was added to GameObject in remote appDomain
86 |
87 | //public List AllAttachedMBs = new List();
88 | //public List _allAttachedMBsValues = new List();
89 |
90 | //bool _changed = false;
91 | //internal bool Changed { get { return _changed; } set { _changed = value; } }
92 |
93 | //public void UpdateValuesArray()
94 | //{
95 | // _allAttachedMBsValues.Clear();
96 | // for (int i = 0; i < AllAttachedMBs.Count; i++)
97 | // {
98 | // _allAttachedMBsValues.Add(AllAttachedMBs[i]);
99 | // }
100 | // _changed = false;
101 | //}
102 |
103 | ////In order to serialization exception not occur while trying to invoke dynamic class method
104 | ////you need to wrap this method into MarshalByRef object's method
105 | //public void UpdateRemote()
106 | //{
107 |
108 | // if (_allAttachedMBsValues.Count != 0)
109 | // {
110 | // for (int i = 0; i < _allAttachedMBsValues.Count; i++)
111 | // {
112 | // _allAttachedMBsValues[i].Update();
113 | // }
114 |
115 | // if (_changed)
116 | // UpdateValuesArray();
117 | // }
118 |
119 | //}
120 | #endregion
121 | }
122 |
123 | //TODO: implement dynamic type compilation with MonoBehaviours
124 | //TODO: implement coroutine compilation
125 | ///
126 | /// Loads CSScriptEngine in separate remote AppDomain, and sends signals to it,
127 | /// to perform operations on input C# code.
128 | ///
129 | public class CSScriptEngineRemote : IDisposable
130 | {
131 |
132 | AppDomain _remoteDomain = null;
133 | public AppDomain RemoteDomain { get { return _remoteDomain; } }
134 |
135 | Action OncompilationSucceededDelegate;
136 | Action OncompilationFailedDelegate;
137 |
138 | RemoteExecutor _remoteExecutor = null;
139 | RemoteExecutor GetRemoteExecutor
140 | {
141 | get
142 | {
143 | try
144 | {
145 | if (_remoteDomain != null)
146 | {
147 | if (_remoteExecutor == null)
148 | {
149 | _remoteExecutor = (RemoteExecutor)_remoteDomain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, typeof(RemoteExecutor).FullName);
150 | _remoteExecutor.Initialize();
151 | }
152 | return _remoteExecutor;
153 | }
154 | else
155 | {
156 | Logger.Log("Remote AppDomain is not loaded.");
157 | return null;
158 | }
159 | }
160 | catch (Exception ex)
161 | {
162 | Logger.Log(ex.ToString());
163 | return null;
164 | }
165 |
166 | }
167 | }
168 |
169 | public void AddUsings(string usings)
170 | {
171 | GetRemoteExecutor.AddUsings(usings);
172 | }
173 |
174 | public void RemoveUsings(string usings)
175 | {
176 | GetRemoteExecutor.RemoveUsings(usings);
177 | }
178 |
179 | ///
180 | /// Sends signal to remote AppDomain to compile C# code
181 | ///
182 | /// String with C# code to compile
183 | public void CompileCode(string code)
184 | {
185 | CompilerOutput tempOutput = GetRemoteExecutor.CompileCode(code);
186 |
187 | ExecuteAppropriateDelegate(tempOutput);
188 | }
189 |
190 | void ExecuteAppropriateDelegate(CompilerOutput tempOutput)
191 | {
192 | if (tempOutput.Errors.Count != 0)
193 | {
194 | if (OncompilationFailedDelegate != null)
195 | OncompilationFailedDelegate(tempOutput);
196 | }
197 | else
198 | {
199 | if (OncompilationSucceededDelegate != null)
200 | OncompilationSucceededDelegate(tempOutput);
201 | }
202 | }
203 |
204 |
205 | ///
206 | /// Sends signal to remote AppDomain to invoke Execute()
207 | /// method of the last compiled IScript object.
208 | ///
209 | public void ExecuteLastCompiledCode()
210 | {
211 | GetRemoteExecutor.ExecuteLastCompiledCode();
212 | }
213 |
214 | ///
215 | /// EXPERIMENTAL:
216 | /// Don't use this method with MonoBehaviours!
217 | /// MonoBehaviours will execute thier Updates in Unity Child Domain
218 | /// even if they were compiled, loaded and added in remote adpDomain
219 | /// That leads to unpredictable results when trying to execute Update() in remote appDomain.
220 | /// So right now using Update() message of dynamically compiled and added to GameObject MonoBehaviour in remote appDomain
221 | /// will result into crash on Unity Child Domain unload, and who knows what oddities and bugs.
222 | ///
223 | public void CompileType(string id, string code)
224 | {
225 | CompilerOutput tempOutput = GetRemoteExecutor.CompileType(id, code);
226 |
227 | ExecuteAppropriateDelegate(tempOutput);
228 | }
229 |
230 | ///
231 | ///EXPERIMENTAL:
232 | ///Don't use this method with MonoBehaviours!
233 | ///MonoBehaviours will execute thier Updates in Unity Child Domain
234 | ///even if they were compiled, loaded and added in remote adpDomain
235 | ///That leads to unpredictable results when trying to execute Update() from MonoBehaviour in remote appDomain
236 | ///So right now using Update() message of dynamically compiled and added to GameObject MonoBehaviour in remote appDomain
237 | ///will result into crash on Unity Child Domain unload, and who knows what oddities and bugs.
238 | ///
239 | public void RemoveTypes(params string[] ids)
240 | {
241 | GetRemoteExecutor.RemoveTypes(ids);
242 | }
243 |
244 | ///
245 | /// Sends signal to CSScriptEngine in remote AppDomain to reset
246 | ///
247 | public void Reset()
248 | {
249 | GetRemoteExecutor.Reset();
250 | }
251 |
252 | public void AddOnCompilationSucceededHandler(Action onCompilationSucceededHandler)
253 | {
254 | OncompilationSucceededDelegate += onCompilationSucceededHandler;
255 | }
256 |
257 | public void RemoveOnCompilationSucceededHandler(Action onCompilationSucceededHandler)
258 | {
259 | OncompilationSucceededDelegate -= onCompilationSucceededHandler;
260 | }
261 |
262 | public void AddOnCompilationFailedHandler(Action onCompilationFailedHandler)
263 | {
264 | OncompilationFailedDelegate += onCompilationFailedHandler;
265 | }
266 |
267 | public void RemoveOnCompilationFailedHandler(Action onCompilationFailedHandler)
268 | {
269 | OncompilationFailedDelegate -= onCompilationFailedHandler;
270 | }
271 |
272 | ///
273 | /// Loads remote AppDomain, so code compilation
274 | /// and execution will be performed in it.
275 | ///
276 | /// Name of the remote AppDomain
277 | public void LoadDomain(string name = "")
278 | {
279 | if (_remoteDomain == null)
280 | {
281 |
282 | AppDomainSetup setup = new AppDomainSetup();
283 | //TODO: Implement proper assembly resolving, maybe using resolving handler
284 | setup.ApplicationBase = Application.dataPath;
285 | setup.PrivateBinPath = Application.dataPath;
286 | setup.ShadowCopyFiles = "true";
287 | setup.ShadowCopyDirectories = setup.ApplicationBase;
288 |
289 | _remoteDomain = AppDomain.CreateDomain(name == "" ? "RemoteDomain" : name, null, setup);
290 |
291 | Logger.Log("RemoteDomain loaded");
292 |
293 | }
294 | else
295 | {
296 | Logger.Log("Remote AppDomain is already loaded");
297 | }
298 | }
299 |
300 | ///
301 | /// Unloads remote AppDomain
302 | ///
303 | public void UnloadDomain()
304 | {
305 | if (_remoteDomain != null)
306 | {
307 | //Dispose any resources allocated by RemoteExecutor first
308 | //Problem here probably
309 | if (_remoteExecutor != null)
310 | _remoteExecutor.Dispose();
311 |
312 | AppDomain.Unload(_remoteDomain);
313 |
314 | _remoteDomain = null;
315 | _remoteExecutor = null;
316 | Logger.Log("RemoteDomain Unloaded");
317 |
318 | }
319 | }
320 |
321 | //Disposable pattern implementation, to unload remote appDomain
322 | public void Dispose()
323 | {
324 | Dispose(true);
325 | GC.SuppressFinalize(this);
326 | }
327 |
328 | protected virtual void Dispose(bool disposing)
329 | {
330 | if (disposing)
331 | {
332 | UnloadDomain();
333 | }
334 | }
335 | }
336 | }
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/CSScriptEngineRemote.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b8f42a9df48db0f43950b3c636e468d0
3 | timeCreated: 1460824793
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/Logger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace UCompile
5 | {
6 | ///
7 | /// Console logger
8 | ///
9 | /// TODO: this primitive logger is mostly a placeholder right now
10 | /// Need to make it serializable to pass it to remote script engine in remote app domain
11 | ///
12 | //[Serializable]
13 | public static class Logger
14 | {
15 | public static void Log(string text)
16 | {
17 | #if UNITY_EDITOR
18 | UnityEngine.Debug.Log(text);
19 | #endif
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/Logger.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 300d5380b8a40dd40b9c38a6d2288def
3 | timeCreated: 1460824815
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/MonoEvaluator.cs:
--------------------------------------------------------------------------------
1 | #region License...
2 |
3 | ////-----------------------------------------------------------------------------
4 | //// Date: 24/01/13 Time: 9:00
5 | //// Module: CSScriptLib.Eval.cs
6 | //// Classes: CSScript
7 | //// Evaluator
8 | ////
9 | //// This module contains the definition of the Evaluator class. Which wraps the common functionality
10 | //// of the Mono.CScript.Evaluator class (compiler as service)
11 | ////
12 | //// Written by Oleg Shilo (oshilo@gmail.com)
13 | ////----------------------------------------------
14 | //// The MIT License (MIT)
15 | //// Copyright (c) 2014 Oleg Shilo
16 | ////
17 | //// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
18 | //// and associated documentation files (the "Software"), to deal in the Software without restriction,
19 | //// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
20 | //// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
21 | //// subject to the following conditions:
22 | ////
23 | //// The above copyright notice and this permission notice shall be included in all copies or substantial
24 | //// portions of the Software.
25 | ////
26 | //// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
27 | //// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28 | //// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29 | //// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30 | //// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 | ////----------------------------------------------
32 |
33 | #endregion Licence...
34 |
35 | using Mono.CSharp;
36 | using System;
37 | using System.Collections.Generic;
38 | using System.Reflection;
39 | using System.Runtime.Serialization;
40 | using System.Text;
41 |
42 | using MCS = Mono.CSharp;
43 |
44 | namespace UCompile
45 | {
46 | ///
47 | /// The exception that is thrown when a the script compiler error occurs.
48 | ///
49 | [Serializable]
50 | public class CompilerException : ApplicationException
51 | {
52 | /////
53 | ///// Gets or sets the errors.
54 | /////
55 | ///// The errors.
56 | //public CompilerErrorCollection Errors { get; set; }
57 | ///
58 | /// Initializes a new instance of the class.
59 | ///
60 | public CompilerException() { }
61 |
62 | ///
63 | /// Initializes a new instance of the class.
64 | ///
65 | /// The object that holds the serialized object data.
66 | /// The contextual information about the source or destination.
67 | public CompilerException(SerializationInfo info, StreamingContext context) : base(info, context) { }
68 |
69 | ///
70 | /// Initializes a new instance of the class.
71 | ///
72 | /// The message.
73 | public CompilerException(string message)
74 | : base(message)
75 | {
76 | }
77 | }
78 |
79 | ///
80 | /// This class encapsulates all errors and warnings
81 | ///
82 | [Serializable]
83 | public class CompilerOutput
84 | {
85 | public CompilerOutput(CompilerException ex)
86 | {
87 | Errors = (List)ex.Data["Errors"];
88 | Warnings = (List)ex.Data["Warnings"];
89 | }
90 |
91 | public CompilerOutput()
92 | {
93 | Errors = new List();
94 | Warnings = new List();
95 | }
96 |
97 | public CompilerOutput(string[] errors, string[] warnings)
98 | {
99 | Errors = new List(errors);
100 | Warnings = new List(warnings);
101 | }
102 |
103 | public CompilerOutput(List errors, List warnings)
104 | {
105 | Errors = errors;
106 | Warnings = warnings;
107 | }
108 |
109 | public List Errors { get; set; }
110 |
111 | public List Warnings { get; set; }
112 | }
113 |
114 | //If you want to implement custom ICompilationSystem,
115 | //make sure your CompileCode and Run methods throw CompilerException on compilation failed.
116 | ///
117 | /// Interface for all dynamic compilation providers.
118 | ///
119 | public interface ICompilationSystem
120 | {
121 | //Properties
122 | List AllReferencedAssemblies { get; }
123 | CompilerOutput CompilationOutput { get; }
124 |
125 | //Methods
126 | Assembly CompileCode(string scriptText);
127 | void Reset();
128 | void SoftReset();
129 | void Run(string sciptText);
130 | void ReferenceAssemblies(params Assembly[] assemblies);
131 | }
132 |
133 |
134 | //TODO: Add async compilation capabilities.
135 | ///
136 | /// Wrapper class for Mono.Csharp.Evaluator
137 | /// compiles code at runtime and loads in-memory assemblies
138 | /// into current app domain.
139 | ///
140 | public class MonoEvaluator : ICompilationSystem
141 | {
142 | ///
143 | /// Gets the compiling result.
144 | ///
145 | /// The compiling result.
146 | public CompilingResult CompilationResult { get; private set; }
147 |
148 | ///
149 | /// More convenient and generic version of CompilationResult
150 | ///
151 | public CompilerOutput CompilationOutput { get; private set; }
152 |
153 | MCS.Evaluator service = null;
154 |
155 | ///
156 | /// Initializes a new instance of the class.
157 | ///
158 | public MonoEvaluator()
159 | {
160 | AllReferencedAssemblies = new List();
161 | Reset();
162 | }
163 | ///
164 | /// Discards current instance of Evaluator, and CompilingResult, and replaces
165 | /// them with new ones. Also nullifies the AllREferencedAssemblies array
166 | ///
167 | public void Reset()
168 | {
169 | CompilationResult = new CompilingResult();
170 |
171 | CompilationOutput = new CompilerOutput();
172 |
173 | service = new MCS.Evaluator(new CompilerContext(new CompilerSettings(), CompilationResult));
174 |
175 | AllReferencedAssemblies = new List();
176 | }
177 |
178 | ///
179 | /// Discards current instance of Evaluator, and CompilingResult, and replaces
180 | /// them with new ones. Previously referenced assemblies get referenced again.
181 | ///
182 | public void SoftReset()
183 | {
184 | service = new MCS.Evaluator(new CompilerContext(new CompilerSettings(), CompilationResult));
185 |
186 | ReferencePreviouslyReferencedAssemblies();
187 |
188 | }
189 |
190 | void ReferencePreviouslyReferencedAssemblies()
191 | {
192 | for(int i = 0;i < AllReferencedAssemblies.Count;i++)
193 | {
194 | service.ReferenceAssembly(AllReferencedAssemblies[i]);
195 | }
196 | }
197 |
198 | static int AsmCounter = 0;
199 |
200 | ///
201 | /// Evaluates (compiles) C# code.
202 | ///
203 | /// The C# script text.
204 | /// The compiled assembly.
205 | public Assembly CompileCode(string scriptText)
206 | {
207 | Assembly result = null;
208 |
209 | HandleCompilingErrors(() =>
210 | {
211 | int id = AsmCounter++;
212 | service.Compile(scriptText + GetConnectionPointClassDeclaration(id));
213 | result = GetCompiledAssembly(id);
214 | });
215 |
216 | return result;
217 | }
218 |
219 | ///
220 | /// Evaluates the specified C# statement. The statement must be "void" (returning no result).
221 | ///
222 | ///
223 | ///
224 | /// MonoEvaluator.Run("using System;");
225 | /// MonoEvaluator.Run("Console.WriteLine(\"Hello World!\");");
226 | ///
227 | ///
228 | /// The C# statement.
229 | public void Run(string scriptText)
230 | {
231 | //Using HandlecompilingErrors will update CompilationOutput, we don't want that
232 | //on Run
233 | //HandleCompilingErrors(() =>
234 | //{
235 | service.Run(scriptText);
236 | //});
237 | }
238 |
239 | Assembly GetCompiledAssembly(int id)
240 | {
241 | string className = GetConnectionPointGetTypeExpression(id);
242 | return ((Type)service.Evaluate(className)).Assembly;
243 | }
244 |
245 | ///
246 | /// Gets a type from the last Compile/Evaluate/Load call.
247 | ///
248 | /// The type name.
249 | /// The type instance
250 | public Type GetCompiledType(string type)
251 | {
252 | return (Type)service.Evaluate("typeof(" + type + ");");
253 | }
254 |
255 | string GetConnectionPointClassDeclaration(int id)
256 | {
257 | return "\n public struct CSS_ConnectionPoint_" + id + " {}";
258 | }
259 | string GetConnectionPointGetTypeExpression(int id)
260 | {
261 | return "typeof(CSS_ConnectionPoint_" + id + ");";
262 | }
263 |
264 | #region Obsolete Assembly Referencing control
265 | //I presume this magic is for assemblies to not be referenced if they already were
266 | //ReflectionImporter Importer
267 | //{
268 | // get
269 | // {
270 | // FieldInfo info = service.GetType().GetField("importer", BindingFlags.Instance | BindingFlags.NonPublic);
271 | // return (ReflectionImporter)info.GetValue(service);
272 | // }
273 | //}
274 |
275 | ///
276 | /// Gets the referenced assemblies. The set of assemblies is get cleared
277 | /// on Reset.
278 | ///
279 | ///
280 | //public Assembly[] GetReferencedAssemblies()
281 | //{
282 | // return Assembly2Definition.Keys.ToArray();
283 | //}
284 |
285 | //static FieldInfo _FieldInfo;
286 | //Dictionary Assembly2Definition
287 | //{
288 | // get
289 | // {
290 | // if (_FieldInfo == null)
291 | // _FieldInfo = Importer.GetType().GetField("assembly_2_definition", BindingFlags.Instance | BindingFlags.NonPublic);
292 | // return (Dictionary)_FieldInfo.GetValue(Importer);
293 | // }
294 | //}
295 |
296 |
297 | ///
298 | /// References the assembly.
299 | /// It is safe to call this method multiple times
300 | /// for the same assembly. If the assembly already referenced it will not
301 | /// be referenced again.
302 | ///
303 | ///
304 | /// The assembly instance.
305 | /// The instance of the .
306 | //public void ReferenceAssembly(Assembly assembly)
307 | //{
308 | // if (!Assembly2Definition.ContainsKey(assembly))
309 | // service.ReferenceAssembly(assembly);
310 | //}
311 |
312 |
313 | //public void ReferenceDomainAssemblies()
314 | //{
315 | // //NOTE: It is important to avoid loading the runtime itself (mscorelib) as it
316 | // //will break the code evaluation (compilation).
317 | // //
318 | // //On .NET mscorelib is filtered out by GlobalAssemblyCache check but
319 | // //on Mono it passes through so there is a need to do a specific check for mscorelib assembly.
320 | // var relevantAssemblies = AppDomain.CurrentDomain.GetAssemblies();
321 |
322 | // //foreach (Assembly asm in relevantAssemblies)
323 | // // UnityEngine.Debug.Log(asm.GetName().Name);
324 |
325 | // //checks if assembly is dynamic
326 | // //relevantAssemblies = relevantAssemblies.Where(x => !IsDynamic(x) && x != mscorelib).ToArray();
327 | // ReferenceAssembly(Assembly.GetExecutingAssembly());
328 |
329 | // //foreach (var asm in relevantAssemblies)
330 | // // ReferenceAssembly(asm);
331 | //}
332 | #endregion
333 |
334 | public List AllReferencedAssemblies { get; private set; }
335 |
336 | public void ReferenceAssemblies(params Assembly[] assemblies)
337 | {
338 | foreach (Assembly asm in assemblies)
339 | {
340 | //NOTE: It is important to avoid loading the runtime itself (mscorelib) as it
341 | // //will break the code evaluation (compilation).
342 | // //
343 | // //On .NET mscorelib is filtered out by GlobalAssemblyCache check but
344 | // //on Mono it passes through so there is a need to do a specific check for mscorelib assembly.
345 | if (!AllReferencedAssemblies.Contains(asm) && !IsDynamic(asm) && asm != mscorelib)
346 | {
347 | service.ReferenceAssembly(asm);
348 | AllReferencedAssemblies.Add(asm);
349 | }
350 |
351 | }
352 | }
353 |
354 | //Get mscorelib assembly
355 | static Assembly mscorelib = 333.GetType().Assembly;
356 | //Little helper method
357 | static bool IsDynamic(Assembly asm)
358 | {
359 | //http://bloggingabout.net/blogs/vagif/archive/2010/07/02/net-4-0-and-notsupportedexception-complaining-about-dynamic-assemblies.aspx
360 | //Will cover both System.Reflection.Emit.AssemblyBuilder and System.Reflection.Emit.InternalAssemblyBuilder
361 | return asm.GetType().FullName.EndsWith("AssemblyBuilder") || asm.Location == null || asm.Location == "";
362 | }
363 |
364 | void HandleCompilingErrors(Action action)
365 | {
366 | CompilationResult.Reset();
367 |
368 | try
369 | {
370 | action();
371 | }
372 | catch (Exception)
373 | {
374 |
375 | if (CompilationResult.HasErrors)
376 | {
377 | throw CompilationResult.CreateException();
378 | }
379 | else
380 | {
381 | //The exception is most likely related to the compilation error
382 | //so do noting. Alternatively (may be in the future) we can add
383 | //it to the errors collection.
384 | //CompilingResult.Errors.Add(e.ToString());
385 | throw;
386 | }
387 | }
388 | finally
389 | {
390 | //We need to reset Evaluator every time after compilation exception occurs
391 | //because Mono throws error on attempt to compile again in this case
392 | if(CompilationResult.HasErrors)
393 | SoftReset();
394 |
395 | //Keep CompilationOutput instance with relevant information about last compilation
396 | UpdateCompilationOutput();
397 | }
398 | }
399 |
400 | void UpdateCompilationOutput()
401 | {
402 |
403 | if (CompilationResult.HasErrors)
404 | CompilationOutput.Errors = CompilationResult.Errors;
405 | if (CompilationResult.HasWarnings)
406 | CompilationOutput.Warnings = CompilationResult.Warnings;
407 | }
408 |
409 | ///
410 | /// Custom implementation of required by
411 | /// API model for handling (reporting) compilation errors.
412 | /// default compiling error reporting (e.g. )
413 | /// is not dev-friendly, thus CompilingResult is acting as an adapter bringing the Mono API close to the
414 | /// traditional CodeDOM error reporting model.
415 | ///
416 | public class CompilingResult : ReportPrinter
417 | {
418 | ///
419 | /// The collection of compiling errors.
420 | ///
421 | public List Errors = new List();
422 |
423 | ///
424 | /// The collection of compiling warnings.
425 | ///
426 | public List Warnings = new List();
427 |
428 | ///
429 | /// Indicates if the last compilation yielded any errors.
430 | ///
431 | /// If set to true indicates presence of compilation error(s).
432 | public bool HasErrors
433 | {
434 | get
435 | {
436 | return Errors.Count > 0;
437 | }
438 | }
439 |
440 | ///
441 | /// Indicates if the last compilation yielded any warnings.
442 | ///
443 | /// If set to true indicates presence of compilation warning(s).
444 | public bool HasWarnings
445 | {
446 | get
447 | {
448 | return Warnings.Count > 0;
449 | }
450 | }
451 |
452 | //TODO: implement custom error hendling, to break dependency on csscript library
453 | ///
454 | /// Creates the containing combined error information.
455 | /// Optionally warnings can also be included in the exception info.
456 | ///
457 | /// The flag indicating if compiler warnings should be included in the error () info.
458 | /// Instance of the .
459 | public CompilerException CreateException()
460 | {
461 | var compileErr = new StringBuilder();
462 |
463 | foreach (string err in Errors)
464 | compileErr.AppendLine(err);
465 |
466 | foreach (string item in Warnings)
467 | compileErr.AppendLine(item);
468 |
469 | CompilerException retval = new CompilerException(compileErr.ToString());
470 |
471 | retval.Data.Add("Errors", Errors);
472 |
473 | retval.Data.Add("Warnings", Warnings);
474 |
475 |
476 | return retval;
477 | }
478 |
479 | ///
480 | /// Clears all errors and warnings.
481 | ///
482 | public new void Reset()
483 | {
484 | Errors.Clear();
485 | Warnings.Clear();
486 | base.Reset();
487 | }
488 |
489 | ///
490 | /// Handles compilation event message.
491 | ///
492 | /// The compilation event message.
493 | /// if set to true [show full path].
494 | public override void Print(Mono.CSharp.AbstractMessage msg, bool showFullPath)
495 | {
496 | string msgInfo = string.Format("{0} {1} CS{2:0000}: {3}", msg.Location, msg.MessageType, msg.Code, msg.Text);
497 | if (!msg.IsWarning)
498 | {
499 | Errors.Add(msgInfo);
500 | }
501 | else
502 | {
503 | Warnings.Add(msgInfo);
504 | }
505 |
506 | }
507 | }
508 | }
509 |
510 |
511 | }
--------------------------------------------------------------------------------
/Assets/UCompile/Core/ScriptEngine/MonoEvaluator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dc56bbbecc285d740b70df15086bb8db
3 | timeCreated: 1460824182
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 73c6ba58d8c589047b34bd332b8a5302
3 | folderAsset: yes
4 | timeCreated: 1468322297
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip.html.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dcd147eef96e3034fb477c35d84f4a4e
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | TextScriptImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 80e90d4961f663d4680461c00bd973fb
3 | folderAsset: yes
4 | timeCreated: 1468322298
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/CompilationScheme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/Documentation/README.md - Grip_files/CompilationScheme.png
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/CompilationScheme.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 819fa8377f0dd124394b7698781d533d
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 0
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: 0.25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 7
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | allowsAlphaSplitting: 0
41 | spriteMode: 0
42 | spriteExtrude: 1
43 | spriteMeshType: 1
44 | alignment: 0
45 | spritePivot: {x: 0.5, y: 0.5}
46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
47 | spritePixelsToUnits: 100
48 | alphaIsTransparency: 0
49 | textureType: -1
50 | buildTargetSettings: []
51 | spriteSheet:
52 | sprites: []
53 | outline: []
54 | spritePackingTag:
55 | userData:
56 | assetBundleName:
57 | assetBundleVariant:
58 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/ExampleProjectGUI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/Documentation/README.md - Grip_files/ExampleProjectGUI.png
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/ExampleProjectGUI.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ce3c52851b2cc464cb1e27bcff1643df
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 0
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: 0.25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 7
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | allowsAlphaSplitting: 0
41 | spriteMode: 0
42 | spriteExtrude: 1
43 | spriteMeshType: 1
44 | alignment: 0
45 | spritePivot: {x: 0.5, y: 0.5}
46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
47 | spritePixelsToUnits: 100
48 | alphaIsTransparency: 0
49 | textureType: -1
50 | buildTargetSettings: []
51 | spriteSheet:
52 | sprites: []
53 | outline: []
54 | spritePackingTag:
55 | userData:
56 | assetBundleName:
57 | assetBundleVariant:
58 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/UcompileStructureScheme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/Documentation/README.md - Grip_files/UcompileStructureScheme.png
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/UcompileStructureScheme.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: abf65b853bcfef44c8bf80c83b8228f9
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 0
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: 0.25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 7
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | allowsAlphaSplitting: 0
41 | spriteMode: 0
42 | spriteExtrude: 1
43 | spriteMeshType: 1
44 | alignment: 0
45 | spritePivot: {x: 0.5, y: 0.5}
46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
47 | spritePixelsToUnits: 100
48 | alphaIsTransparency: 0
49 | textureType: -1
50 | buildTargetSettings: []
51 | spriteSheet:
52 | sprites: []
53 | outline: []
54 | spritePackingTag:
55 | userData:
56 | assetBundleName:
57 | assetBundleVariant:
58 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/frameworks-b1642e37b45963af25ee113eaec46c25df28655ab893baf240e31a7dd0a215ea.css.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9d3c221be648c3149a62fa151bde6934
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/github-e9228d764bc8fd6a49739e9a2e155477e49f87e735d550f10ae45b3cdb394a95.css.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c298010358c433c45a88596288eb437e
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/logo github banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/Documentation/README.md - Grip_files/logo github banner.png
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/logo github banner.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 811d6b79b33a8cd4facbd212f4e9dfbf
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | TextureImporter:
6 | fileIDToRecycleName: {}
7 | serializedVersion: 2
8 | mipmaps:
9 | mipMapMode: 0
10 | enableMipMap: 1
11 | linearTexture: 0
12 | correctGamma: 0
13 | fadeOut: 0
14 | borderMipMap: 0
15 | mipMapFadeDistanceStart: 1
16 | mipMapFadeDistanceEnd: 3
17 | bumpmap:
18 | convertToNormalMap: 0
19 | externalNormalMap: 0
20 | heightScale: 0.25
21 | normalMapFilter: 0
22 | isReadable: 0
23 | grayScaleToAlpha: 0
24 | generateCubemap: 0
25 | cubemapConvolution: 0
26 | cubemapConvolutionSteps: 7
27 | cubemapConvolutionExponent: 1.5
28 | seamlessCubemap: 0
29 | textureFormat: -1
30 | maxTextureSize: 2048
31 | textureSettings:
32 | filterMode: -1
33 | aniso: -1
34 | mipBias: -1
35 | wrapMode: -1
36 | nPOTScale: 1
37 | lightmap: 0
38 | rGBM: 0
39 | compressionQuality: 50
40 | allowsAlphaSplitting: 0
41 | spriteMode: 0
42 | spriteExtrude: 1
43 | spriteMeshType: 1
44 | alignment: 0
45 | spritePivot: {x: 0.5, y: 0.5}
46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
47 | spritePixelsToUnits: 100
48 | alphaIsTransparency: 0
49 | textureType: -1
50 | buildTargetSettings: []
51 | spriteSheet:
52 | sprites: []
53 | outline: []
54 | spritePackingTag:
55 | userData:
56 | assetBundleName:
57 | assetBundleVariant:
58 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/site-3b27741f2e22b48854ecee715112d86949a7c9e4e502f41739c4578cc65283da.css.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 63cca9e37731f8c4bb42478410acd08e
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/system-fonts-b4cd5a28f837260371d5a61872bda2262ec244fc0c92bc9243fec8d26d246840.css:
--------------------------------------------------------------------------------
1 | .header-search-wrapper,.header-search-input{padding-top:0;padding-bottom:0}.header-search-wrapper{padding-right:0;padding-left:0}.btn,.text-bold,.text-emphasized,label,strong,.logo-subbrand,.header-nav-link,.table-list-header-toggle.states .selected,.issue-title-link,.label,.diffstat,.subnav-item,.social-count,.user-mention,.team-mention,.sidebar-assignee .assignee,.pagination a,.pagination em,.pagination span,.counter,.select-menu-tabs a,.select-menu-tab-nav,.state,.discussion-item-entity,.discussion-item .author,.mini-repo-list-item .repo,.news .alert .title,.diff-options-content .selected,.vcard-stat-count,.issues-reset-query,.bubble-expand,.discussion-block-title .username,.list-item-title,.tabs>a{font-weight:600}h1,.markdown-body h1,h2,.markdown-body h2,h3,.markdown-body h3,h4,.markdown-body h4,h5,.markdown-body h5,h6,.markdown-body h6{line-height:1.5}h1,.markdown-body h1{font-size:32px;font-weight:600}h2,.markdown-body h2{font-size:24px;font-weight:600}h3,.markdown-body h3{font-size:20px;font-weight:600}h4,.markdown-body h4{font-size:16px;font-weight:600}h5,.markdown-body h5{font-size:14px;font-weight:600}h6,.markdown-body h6{font-size:12px;font-weight:600}.h1,.h2,.h3,.h4,.h5,.h6{font-weight:600 !important}.h1{font-size:32px !important}.h2{font-size:24px !important}.h3{font-size:20px !important}.h4{font-size:16px !important}.h5{font-size:14px !important}.text-normal{font-weight:normal !important}.octicon{vertical-align:text-bottom}.subnav-item{padding-top:6px;padding-bottom:6px}.pr-details .state{width:80px}.stats-switcher-viewport{height:41px}.label{font-size:12px}.counter{font-size:12px}.news .alert .dashboard-event-icon{top:18px}.form-checkbox input[type="radio"],.form-checkbox input[type="checkbox"]{margin-top:5px}.recently-touched-branches li{line-height:inherit}.commit-tease{font-size:13px}.commit-tease-sha{font-size:90%}.blog-post-title{line-height:1.25}.alt-merge-options{font-size:12px}.diffbar-item,.subset-files-tab{font-size:13px}.labels-list-item .label{height:auto;line-height:2}.site-header .header-search .header-search-input{min-height:34px}.site-header .site-header-nav-main .nav-item{padding-top:7px;padding-bottom:25px}.site-header .site-header-nav-secondary .nav-item{padding-top:7px;padding-bottom:7px}.issues-listing .Box-body-row .h3{font-size:16px !important}.recent-gists-container .your-gists{font-size:13px}.gist-header .header-logo-wordmark .logo-subbrand{display:inline-block;font-weight:normal}.toolbar-commenting{margin-top:0}.discussion-item-ref-title{font-size:16px}.discussion-item-ref .state{margin-top:0}.discussion-item-context-icon{margin-top:0}.merge-branch-heading{font-size:16px}.notifications-list .boxed-group .text-success{width:220px;font-size:13px}.tree-finder-input,.tree-finder-input:focus{top:0;height:auto;padding:0;font-size:inherit;line-height:inherit}.branch-action-item{font-size:13px}.profilecols .filter-bar .form-control{width:240px}.header-search-scope{font-size:12px}.nav-bar-inner .brand-logo-invertocat .octicon{vertical-align:text-top}.discussion-item-icon .octicon{vertical-align:text-bottom}.dropdown-caret{vertical-align:middle}.toolbar-item .dropdown-caret{display:inline-block;float:none;margin-top:0;margin-left:-3px}.repo-private-label,.gist-secret-label{padding-bottom:4px;font-size:12px;line-height:1;text-transform:capitalize}.file-actions{font-size:13px}.boxed-group-inner{font-size:inherit}.user-nav .octicon-bell{margin-top:0}.select-menu-item-heading{line-height:1.5}.sidebar-assignee .select-menu-item-heading{line-height:1.1}.select-menu-item-text .description{margin-top:0}.blob-code,.blob-num{line-height:20px}.nav-bar-tabs a{padding-left:45px}.nav-bar-tabs a .octicon,.nav-bar-tabs a .avatar{position:static;float:left;margin-top:3px;margin-left:-30px}.nav-bar-tabs a .octicon{width:20px}.post-title{line-height:1.25}.post-content{padding:0}.gh-header-edit .edit-issue-title{padding-top:7px;padding-bottom:7px}.audit-search-form .audit-log-search-query{width:250px}.team-grid .team-members .btn-sm{margin-top:1px;margin-bottom:1px}.new_repository .btn-invisible{margin-top:0 !important}.file-navigation-option .input-group .form-control{height:28px}.stats-switcher-viewport.is-revealing-lang-stats .stats-switcher-wrapper{top:-41px}
2 |
3 |
--------------------------------------------------------------------------------
/Assets/UCompile/Documentation/README.md - Grip_files/system-fonts-b4cd5a28f837260371d5a61872bda2262ec244fc0c92bc9243fec8d26d246840.css.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 11713a8626300fc49a0383b0a022ed8c
3 | timeCreated: 1468322298
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3de1e9f67721dda42a25a6e52ea58536
3 | folderAsset: yes
4 | timeCreated: 1460825053
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/CheatSheet.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ad4eaa1b687afdf4dbd7aa1ea0c37394
3 | folderAsset: yes
4 | timeCreated: 1467110147
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/CheatSheet/CheatSheet.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UCompile;
3 | using System.Collections;
4 | using System;
5 |
6 | //This namespace is for demonstration of how usings management system in CSScriptEngine
7 | //can allow you to restrict access of resources to dynamic code
8 | namespace SomeCustomNamespace
9 | {
10 |
11 | public class HeyPrinter
12 | {
13 | public void PrintHey()
14 | {
15 | Debug.Log("Hey!");
16 | }
17 | }
18 |
19 | }
20 |
21 | public class CheatSheet : MonoBehaviour {
22 |
23 | #region CSScriptEngine examples
24 |
25 | //-------------------------------------------------------------------------------------------------
26 |
27 | //Compile simple methodless code
28 | void CompileCode()
29 | {
30 | CSScriptEngine engine = new CSScriptEngine();
31 |
32 | engine.AddUsings("using UnityEngine;");
33 |
34 | IScript result = engine.CompileCode(@"Debug.Log(""Hey!"");");
35 |
36 | result.Execute();
37 |
38 | }
39 |
40 | //-------------------------------------------------------------------------------------------------
41 |
42 | //Compile custom type, and then invoke it's method via CompileCode
43 | void CompileType()
44 | {
45 |
46 | CSScriptEngine engine = new CSScriptEngine();
47 |
48 | engine.AddUsings("using UnityEngine;");
49 |
50 | string typeCode = @"
51 |
52 | public class SimpleType
53 | {
54 | public void PrintHey()
55 | {
56 | Debug.Log(""Hey!"");
57 | }
58 | }
59 |
60 | ";
61 |
62 | engine.CompileType("SimpleType", typeCode);
63 |
64 | IScript result = engine.CompileCode(@"
65 | SimpleType sm = new SimpleType();sm.PrintHey();
66 | ");
67 |
68 | result.Execute();
69 | }
70 |
71 | //-------------------------------------------------------------------------------------------------
72 |
73 | //Compile custom type, and then compile another type, using previously compiled type in its code, and then
74 | //execute last compiled types method via CompileCode
75 | void CompileMultipleTypes()
76 | {
77 |
78 | CSScriptEngine engine = new CSScriptEngine();
79 |
80 | engine.AddUsings("using UnityEngine;");
81 |
82 | string typeCode = @"
83 |
84 | public class SimpleType
85 | {
86 | public void PrintHey()
87 | {
88 | Debug.Log(""Hey!"");
89 | }
90 | }
91 |
92 | ";
93 |
94 | engine.CompileType("SimpleType", typeCode);
95 |
96 | string anotherTypeCode = @"
97 |
98 | public class AnotherSimpleType
99 | {
100 | public void InvokeSimpleTypesPrintHey()
101 | {
102 | Debug.Log(""Greetings from AnotherSimpleType! Invoking SimpleTypes PrintHey method..."");
103 | SimpleType sm = new SimpleType(); sm.PrintHey();
104 | }
105 | }
106 |
107 | ";
108 |
109 | engine.CompileType("AnotherSimpleType", anotherTypeCode);
110 |
111 | IScript result = engine.CompileCode(@"
112 | AnotherSimpleType sm = new AnotherSimpleType();sm.InvokeSimpleTypesPrintHey();
113 | ");
114 |
115 | result.Execute();
116 | }
117 |
118 | //-------------------------------------------------------------------------------------------------
119 |
120 | //Here we determine which method is going to automatically be invoked when compilation ends with errors
121 | void AddCompilationFailedHandler()
122 | {
123 | CSScriptEngine engine = new CSScriptEngine();
124 |
125 | engine.AddOnCompilationFailedHandler(OnCompilationFailedAction);
126 |
127 | engine.CompileCode("This will result in error");
128 |
129 | engine.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);
130 | }
131 |
132 | //Method of type Action that will be executed on failed compilation(with errors)
133 | //Outputs errors occured during compilation to editor console
134 | public void OnCompilationFailedAction(CompilerOutput output)
135 | {
136 | for (int i = 0; i < output.Errors.Count; i++)
137 | Debug.LogError(output.Errors[i]);
138 | for (int i = 0; i < output.Warnings.Count; i++)
139 | Debug.LogWarning(output.Warnings[i]);
140 | }
141 |
142 | //-------------------------------------------------------------------------------------------------
143 |
144 | //Here we determine which method is going to automatically be invoked when compilation ends without errors
145 | void AddCompilationSucceededHandler()
146 | {
147 | CSScriptEngine engine = new CSScriptEngine();
148 |
149 | engine.AddOnCompilationSucceededHandler(OnCompilationSucceededAction);
150 |
151 | engine.CompileCode("string warningCauser = \"This will result in warning, but compillation succeeds\";");
152 |
153 | engine.RemoveOnCompilationSucceededHandler(OnCompilationSucceededAction);
154 | }
155 |
156 | //Method of type Action that will be executed on succesfull compilation(without errors)
157 | //Outputs warnings occured during compilation to editor console
158 | public void OnCompilationSucceededAction(CompilerOutput output)
159 | {
160 | for (int i = 0; i < output.Warnings.Count; i++)
161 | Debug.LogWarning(output.Warnings[i]);
162 | }
163 |
164 | //-------------------------------------------------------------------------------------------------
165 |
166 | //Remove compiled type from system, now this type is inaccessible to dynamic code
167 | void RemoveType()
168 | {
169 | CSScriptEngine engine = new CSScriptEngine();
170 |
171 | engine.AddUsings("using UnityEngine;");
172 |
173 | engine.AddOnCompilationFailedHandler(OnCompilationFailedAction);
174 |
175 | string typeCode = @"
176 |
177 | public class SimpleType
178 | {
179 | public void PrintHey()
180 | {
181 | Debug.Log(""Hey!"");
182 | }
183 | }
184 |
185 | ";
186 |
187 | engine.CompileType("SimpleType", typeCode);
188 |
189 | string anotherTypeCode = @"
190 |
191 | public class AnotherSimpleType
192 | {
193 | public void InvokeSimpleTypesPrintHey()
194 | {
195 | Debug.Log(""Greetings from AnotherSimpleType! Invoking SimpleTypes PrintHey method..."");
196 | SimpleType sm = new SimpleType(); sm.PrintHey();
197 | }
198 | }
199 |
200 | ";
201 |
202 | engine.CompileType("AnotherSimpleType", anotherTypeCode);
203 |
204 | engine.RemoveTypes("AnotherSimpleType");
205 |
206 | //This will cause a compilation error, beacause we removed AnotherSimpleType
207 | engine.CompileCode(@"
208 | AnotherSimpleType sm = new AnotherSimpleType();
209 | ");
210 |
211 | engine.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);
212 |
213 | }
214 |
215 | //-------------------------------------------------------------------------------------------------
216 |
217 | //add using directives to CSScriptEngine, to control what is exposed to dynamic code
218 | void AddUsings()
219 | {
220 | CSScriptEngine engine = new CSScriptEngine();
221 |
222 | engine.AddOnCompilationFailedHandler(OnCompilationFailedAction);
223 |
224 | //There's no usings right now in system, so nothing, apart from basic types is accesible to dynamic code
225 | engine.CompileCode("Debug.Log(\"This will result in an error, because Debug is a part of UnityEngine namespace\");");
226 |
227 | //Here we add using UnityEngine to system, so everything in this namespace is accessible now
228 | engine.AddUsings("using UnityEngine;");
229 |
230 | engine.CompileCode("Debug.Log(\"Now compilation of this code will succeed\");").Execute();
231 |
232 | engine.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);
233 |
234 | }
235 |
236 | //-------------------------------------------------------------------------------------------------
237 |
238 | //Add using of custom namespace, this way you can restrict access of resources to only your custom namespace
239 | void AddCustomNamespaceUsings()
240 | {
241 | CSScriptEngine engine = new CSScriptEngine();
242 |
243 | //Here we add using UnityEngine to system, so everything in this namespace is accessible now
244 | engine.AddUsings("using SomeCustomNamespace;");
245 |
246 | engine.CompileCode("HeyPrinter hp = new HeyPrinter(); hp.PrintHey();").Execute();
247 |
248 | }
249 |
250 | //-------------------------------------------------------------------------------------------------
251 |
252 | //Removes usings from system, so it's namespace resources become inaccessible for dynamic code
253 | void RemoveUsings()
254 | {
255 | CSScriptEngine engine = new CSScriptEngine();
256 |
257 | engine.AddOnCompilationFailedHandler(OnCompilationFailedAction);
258 |
259 | engine.AddUsings("using SomeCustomNamespace;");
260 |
261 | engine.CompileCode("HeyPrinter hp = new HeyPrinter(); hp.PrintHey();").Execute();
262 |
263 | engine.RemoveUsings("using SomeCustomNamespace;");
264 |
265 | //Now this will result in error
266 | engine.CompileCode("HeyPrinter hp = new HeyPrinter(); hp.PrintHey();");
267 |
268 | engine.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);
269 |
270 | }
271 |
272 | //-------------------------------------------------------------------------------------------------
273 |
274 | //Coroutine compilation is similar to methodless code compilation, but with some nuances.
275 | void CompileCoroutine()
276 | {
277 | CSScriptEngine engine = new CSScriptEngine();
278 |
279 | engine.AddUsings("using UnityEngine;");
280 |
281 | //CompileCoroutine returns IEnumerable object, so you need to use GetEnumerator on it in order to
282 | //be able to pass it to StartCoroutine
283 | IEnumerator coroutine = engine.CompileCoroutine(@"yield return new WaitForSeconds(1f);Debug.Log(""Hey!"");").GetEnumerator();
284 |
285 | StartCoroutine(coroutine);
286 |
287 | }
288 |
289 | #endregion CSScriptEngine examples
290 |
291 | #region CSScriptEngineRemote examples
292 |
293 | //With CSScriptEngineRemote you must always invoke LoadDomain before using it,
294 | //and always invoke Unloaddomain or Dispose when you're done using it
295 | void RemoteCompileCode()
296 | {
297 | //Let's check that no dynamic assemblies were loaded in main appDomain
298 | Debug.Log("Assemblies currently loaded in main appdomain: " + AppDomain.CurrentDomain.GetAssemblies().Length);
299 |
300 | //You can ensure dispose call by utilizing using block, for example
301 | using (CSScriptEngineRemote engineRemote = new CSScriptEngineRemote())
302 | {
303 | engineRemote.LoadDomain();
304 |
305 | engineRemote.AddUsings("using UnityEngine;");
306 |
307 | engineRemote.CompileCode(@"Debug.Log(""Hey!"");");
308 |
309 | engineRemote.ExecuteLastCompiledCode();
310 | }
311 |
312 | Debug.Log("Assemblies currently loaded in main appdomain: " + AppDomain.CurrentDomain.GetAssemblies().Length);
313 | }
314 |
315 | //Remember, you can't compile MonoBehaviours with CSSCriptEngineRemote, stick to
316 | //plain C# classes for safety
317 | void RemoteCompileType()
318 | {
319 |
320 | CSScriptEngineRemote engineRemote = new CSScriptEngineRemote();
321 |
322 | engineRemote.LoadDomain();//Important!
323 |
324 | engineRemote.AddUsings("using UnityEngine;");
325 |
326 | string typeCode = @"
327 |
328 | public class SimpleType
329 | {
330 | public void PrintHey()
331 | {
332 | Debug.Log(""Hey!"");
333 | }
334 | }
335 |
336 | ";
337 |
338 | engineRemote.CompileType("SimpleType", typeCode);
339 |
340 | engineRemote.CompileCode(@"
341 | SimpleType sm = new SimpleType();sm.PrintHey();
342 | ");
343 |
344 | engineRemote.ExecuteLastCompiledCode();
345 |
346 | engineRemote.UnloadDomain();//Important!
347 | }
348 |
349 | #endregion CSScriptEngineRemote examples
350 |
351 | void Update ()
352 | {
353 | #region CSScriptEngine
354 |
355 | if (Input.GetKeyDown(KeyCode.A))
356 | {
357 | CompileCode();
358 | }
359 | if (Input.GetKeyDown(KeyCode.B))
360 | {
361 | CompileType();
362 | }
363 | if (Input.GetKeyDown(KeyCode.C))
364 | {
365 | CompileMultipleTypes();
366 | }
367 | if (Input.GetKeyDown(KeyCode.D))
368 | {
369 | AddCompilationFailedHandler();
370 | }
371 | if (Input.GetKeyDown(KeyCode.E))
372 | {
373 | AddCompilationSucceededHandler();
374 | }
375 | if (Input.GetKeyDown(KeyCode.F))
376 | {
377 | RemoveType();
378 | }
379 | if (Input.GetKeyDown(KeyCode.G))
380 | {
381 | AddUsings();
382 | }
383 | if (Input.GetKeyDown(KeyCode.H))
384 | {
385 | AddCustomNamespaceUsings();
386 | }
387 | if (Input.GetKeyDown(KeyCode.I))
388 | {
389 | RemoveUsings();
390 | }
391 | if (Input.GetKeyDown(KeyCode.J))
392 | {
393 | CompileCoroutine();
394 | }
395 |
396 | #endregion CSScriptEngine
397 |
398 | #region CSSCriptEngineRemote
399 |
400 | if (Input.GetKeyDown(KeyCode.K))
401 | {
402 | RemoteCompileCode();
403 | }
404 | if (Input.GetKeyDown(KeyCode.L))
405 | {
406 | RemoteCompileType();
407 | }
408 |
409 | #endregion CSSCriptEngineRemote
410 | }
411 | }
412 |
413 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/CheatSheet/CheatSheet.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 89c57bc0fdf80a84bb3c8d0287b48e05
3 | timeCreated: 1466856022
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/CheatSheet/CheatSheetScene.unity:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/ExampleProject/CheatSheet/CheatSheetScene.unity
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/CheatSheet/CheatSheetScene.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e6a4a7b52ef19034385a80817b3519fe
3 | timeCreated: 1466856289
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/ExampleCode.txt:
--------------------------------------------------------------------------------
1 | Example code
2 |
3 | ------------------------------------------------
4 |
5 | ------------------------------------------------
6 |
7 | Create cube
8 |
9 | Code window code:
10 |
11 | Cube cube = new Cube();
12 |
13 | ------------------------------------------------
14 |
15 | ------------------------------------------------
16 |
17 | Create cube with plain class
18 |
19 | Type window code:
20 |
21 | public class CubeCreator
22 | {
23 | public void CreateCube()
24 | {
25 | Cube cube = new Cube();
26 | }
27 | }
28 |
29 | Code window code:
30 |
31 | CubeCreator creator = new CubeCreator(); creator.CreateCube();
32 |
33 | ------------------------------------------------
34 |
35 | ------------------------------------------------
36 |
37 | Change cube color on space press with MonoBehaviour
38 |
39 | Type window code:
40 |
41 | public class ColourChanger : MonoBehaviour
42 | {
43 | void Update()
44 | {
45 | if (Input.GetKeyDown(KeyCode.Space))
46 | {
47 | this.gameObject.GetComponent().material.color = new Color(Random.value, Random.value, Random.value);
48 | }
49 | }
50 | }
51 |
52 | Code window code:
53 |
54 | Cube cube = new Cube(); cube._cube.AddComponent();
55 |
56 | ------------------------------------------------
57 |
58 | ------------------------------------------------
59 | Control cube movement with arrow keys
60 |
61 | Type window code:
62 |
63 | public class MoverController : MonoBehaviour
64 | {
65 | void Update()
66 | {
67 | if (Input.GetKeyDown(KeyCode.UpArrow))
68 | {
69 | Mover.MoveItUp(new Cube(this.gameObject), Mathf.Infinity, 0);
70 | }
71 | if (Input.GetKeyUp(KeyCode.UpArrow))
72 | {
73 | Mover.StopAllMovement();
74 | }
75 |
76 | if (Input.GetKeyDown(KeyCode.DownArrow))
77 | {
78 | Mover.MoveItDown(new Cube(this.gameObject), Mathf.Infinity, 0);
79 | }
80 | if (Input.GetKeyUp(KeyCode.DownArrow))
81 | {
82 | Mover.StopAllMovement();
83 | }
84 |
85 | if (Input.GetKeyDown(KeyCode.LeftArrow))
86 | {
87 | Mover.MoveItLeft(new Cube(this.gameObject), Mathf.Infinity, 0);
88 | }
89 | if (Input.GetKeyUp(KeyCode.LeftArrow))
90 | {
91 | Mover.StopAllMovement();
92 | }
93 |
94 | if (Input.GetKeyDown(KeyCode.RightArrow))
95 | {
96 | Mover.MoveItRight(new Cube(this.gameObject), Mathf.Infinity, 0);
97 | }
98 | if (Input.GetKeyUp(KeyCode.RightArrow))
99 | {
100 | Mover.StopAllMovement();
101 | }
102 | }
103 | }
104 |
105 | Code window code:
106 |
107 | Cube cube = new Cube(); cube._cube.AddComponent();
108 |
109 | ------------------------------------------------
110 |
111 | ------------------------------------------------
112 |
113 | Create bubble sort animation
114 |
115 | Bubble sort code, be sure to toggle Animation on, before entering this
116 |
117 | Code window code:
118 |
119 | Column[] clmnArray = Utility.GenerateColumnArray(5,4,3,2,1);
120 |
121 | for (int i = 0; i clmnArray[j + 1])
126 | {
127 | yield return Utility.PrettySwap(ref clmnArray[j],ref clmnArray[j + 1]);
128 | }
129 | }
130 | }
131 |
132 | ------------------------------------------------
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/ExampleCode.txt.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1cd315f392ef2824cbf3e0263e02d880
3 | timeCreated: 1465737217
4 | licenseType: Free
5 | TextScriptImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Prefabs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e42f3f498310be847b8ba90827f5606a
3 | folderAsset: yes
4 | timeCreated: 1460825239
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Prefabs/GUI.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 35c274b22f83b97429d8a5fccc8a375e
3 | folderAsset: yes
4 | timeCreated: 1460884382
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Prefabs/GUI/Canvas.prefab:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/ExampleProject/Prefabs/GUI/Canvas.prefab
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Prefabs/GUI/Canvas.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2c35721e1d42613498eb68235e1f123e
3 | timeCreated: 1460884406
4 | licenseType: Free
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Prefabs/GUI/ClassNameButton.prefab:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/ExampleProject/Prefabs/GUI/ClassNameButton.prefab
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Prefabs/GUI/ClassNameButton.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dc669b31ce2de9d4bb136d9c65ca0b61
3 | timeCreated: 1460884424
4 | licenseType: Free
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Prefabs/GUI/EventManager.prefab:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/ExampleProject/Prefabs/GUI/EventManager.prefab
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Prefabs/GUI/EventManager.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dba8598e85fccac4cb764ec11607b78a
3 | timeCreated: 1460825314
4 | licenseType: Free
5 | NativeFormatImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c3e9b8a80e19c3246bfbec7a16609510
3 | folderAsset: yes
4 | timeCreated: 1460825111
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scenes/Main.unity:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SoapCode/UCompile/0f2e369bd9e20902446ed97eb1fc5a133f3b456c/Assets/UCompile/ExampleProject/Scenes/Main.unity
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scenes/Main.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 690a1341d1027a646bced9bf71db4fc6
3 | timeCreated: 1460884772
4 | licenseType: Free
5 | DefaultImporter:
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e5a6549385955894c92fb5dd53f5ea4e
3 | folderAsset: yes
4 | timeCreated: 1460825121
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scripts/GUI.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 37f636e2c98323d4fa23a8ab6e0a6e6f
3 | folderAsset: yes
4 | timeCreated: 1460879792
5 | licenseType: Free
6 | DefaultImporter:
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scripts/GUI/CSScriptInterpreterView.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using UCompile;
4 | using System.Collections.Generic;
5 | using System;
6 |
7 | namespace ExampleProjectGUI
8 | {
9 |
10 | public class CSScriptInterpreterView : MonoBehaviour
11 | {
12 |
13 | CSScriptEngine _engine;
14 | CSScriptEngineRemote _engineRemote;
15 |
16 | IScript _lastCompiledScript = null;
17 | IEnumerable _lastCompiledCoroutine = null;
18 | [HideInInspector]
19 | public bool Remote = false;
20 | public bool ResetSceneOnExecute = false;
21 | bool _currentlyCompilingCoroutine = false;
22 | bool _currentlyCompilingCode = false;
23 |
24 | bool _lastCompilationSucceeded = true;
25 |
26 | void Awake()
27 | {
28 | _engine = new CSScriptEngine();
29 | _engineRemote = new CSScriptEngineRemote();
30 | }
31 |
32 | void Start()
33 | {
34 | _engine.AddUsings("using WhitelistAPI;");
35 | _engine.AddUsings("using UnityEngine;");
36 |
37 | }
38 |
39 | void Update()
40 | {
41 | if (Remote)
42 | {
43 | if (_engineRemote.RemoteDomain == null)
44 | {
45 | _engineRemote.LoadDomain("RemoteDomain");
46 | _engineRemote.AddUsings("using WhitelistAPI;");
47 | _engineRemote.AddUsings("using UnityEngine;");
48 | _engineRemote.AddUsings("using System;");
49 | }
50 | if (!GameObjectWatcher.Initialized)
51 | GameObjectWatcher.Initialize();
52 | }
53 | else
54 | if (_engineRemote.RemoteDomain != null)
55 | {
56 | GameObjectWatcher.DestroyAllDynamicGOs();
57 | if (!ResetSceneOnExecute)
58 | GameObjectWatcher.Disable();
59 | _engineRemote.UnloadDomain();
60 | }
61 | if (ResetSceneOnExecute)
62 | {
63 | if (!GameObjectWatcher.Initialized)
64 | GameObjectWatcher.Initialize();
65 | }
66 | else
67 | {
68 | if (GameObjectWatcher.Initialized)
69 | GameObjectWatcher.Disable();
70 | }
71 | }
72 |
73 | void OnEnable()
74 | {
75 | _engine.AddOnCompilationSucceededHandler(OnCompilationSucceededAction);
76 | _engine.AddOnCompilationFailedHandler(OnCompilationFailedAction);
77 | _engineRemote.AddOnCompilationSucceededHandler(OnCompilationSucceededAction);
78 | _engineRemote.AddOnCompilationFailedHandler(OnCompilationFailedAction);
79 |
80 | EventManager.Instance.AddListener(OnCompileButton);
81 | EventManager.Instance.AddListener(OnExecuteButton);
82 | EventManager.Instance.AddListener(OnCompileAndAddTypeButton);
83 | EventManager.Instance.AddListener(OnDeleteTypeButton);
84 | EventManager.Instance.AddListener(OnAnimationToggleValueChanged);
85 | EventManager.Instance.AddListener(OnCodeToggleValueChanged);
86 |
87 | }
88 |
89 | void OnDisable()
90 | {
91 | //OnDisable later then EventManager's OnApplicationQuit where It's Instance property gets nullified
92 | //That causes null reference exception, so let's add this check to prevent that
93 | if (EventManager.Instance != null)
94 | {
95 | _engine.RemoveOnCompilationSucceededHandler(OnCompilationSucceededAction);
96 | _engine.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);
97 | _engineRemote.RemoveOnCompilationSucceededHandler(OnCompilationSucceededAction);
98 | _engineRemote.RemoveOnCompilationFailedHandler(OnCompilationFailedAction);
99 |
100 | EventManager.Instance.RemoveListener(OnCompileButton);
101 | EventManager.Instance.RemoveListener(OnExecuteButton);
102 | EventManager.Instance.RemoveListener(OnCompileAndAddTypeButton);
103 | EventManager.Instance.RemoveListener(OnDeleteTypeButton);
104 | }
105 | if (Remote)
106 | if (_engineRemote.RemoteDomain != null)
107 | _engineRemote.Dispose();
108 | }
109 |
110 | public void OnCompileButton(CompilationEvent cmpEv)
111 | {
112 | if (!Remote)
113 | {
114 | if (_currentlyCompilingCode)
115 | _lastCompiledScript = _engine.CompileCode(cmpEv.Code);
116 | else if (_currentlyCompilingCoroutine)
117 | _lastCompiledCoroutine = _engine.CompileCoroutine(cmpEv.Code);
118 | }
119 | else
120 | {
121 | if (_currentlyCompilingCode)
122 | _engineRemote.CompileCode(cmpEv.Code);
123 | }
124 | }
125 |
126 | public void OnExecuteButton(ExecutionEvent cmpEv)
127 | {
128 | if (!Remote)
129 | {
130 | if (_currentlyCompilingCode && _lastCompiledScript != null)
131 | _lastCompiledScript.Execute();
132 | else if (_currentlyCompilingCoroutine && _lastCompiledCoroutine != null)
133 | StartCoroutine(_lastCompiledCoroutine.GetEnumerator());
134 | }
135 | else
136 | {
137 | if (_currentlyCompilingCode)
138 | _engineRemote.ExecuteLastCompiledCode();
139 | }
140 |
141 | }
142 |
143 | public void OnCompileAndAddTypeButton(CompileTypeEvent ev)
144 | {
145 | if (!Remote)
146 | _engine.CompileType(ev.TypeID, ev.Code);
147 | else
148 | _engineRemote.CompileType(ev.TypeID, ev.Code);
149 |
150 | if(_lastCompilationSucceeded)
151 | EventManager.Instance.QueueEvent(new TypeCompilationSucceededEvent(ev));
152 |
153 | }
154 |
155 | public void OnDeleteTypeButton(DeleteTypeEvent ev)
156 | {
157 | if (!Remote)
158 | _engine.RemoveTypes(ev.TypeID);
159 | else
160 | _engineRemote.RemoveTypes(ev.TypeID);
161 |
162 | }
163 |
164 | public void OnAnimationToggleValueChanged(CurrentlyCompilingAnimationEvent ev)
165 | {
166 | _currentlyCompilingCoroutine = true;
167 | _currentlyCompilingCode = false;
168 | }
169 | public void OnCodeToggleValueChanged(CurrentlyCompilingCodeEvent ev)
170 | {
171 | _currentlyCompilingCode = true;
172 | _currentlyCompilingCoroutine = false;
173 | }
174 |
175 | public void OnRemoteToggleValueChanged()
176 | {
177 | Remote = !Remote;
178 | }
179 |
180 | public void OnCompilationSucceededAction(CompilerOutput output)
181 | {
182 | for (int i = 0; i < output.Warnings.Count; i++)
183 | Debug.LogWarning(output.Warnings[i]);
184 |
185 | _lastCompilationSucceeded = true;
186 | }
187 |
188 | public void OnCompilationFailedAction(CompilerOutput output)
189 | {
190 | for (int i = 0; i < output.Errors.Count; i++)
191 | Debug.LogError(output.Errors[i]);
192 | for (int i = 0; i < output.Warnings.Count; i++)
193 | Debug.LogWarning(output.Warnings[i]);
194 |
195 | _lastCompilationSucceeded = false;
196 | }
197 |
198 | }
199 |
200 | //This class will watch over dynamically created GameObjects, and delete them all before each
201 | //Execute.
202 | internal static class GameObjectWatcher
203 | {
204 | public static List AllDynamicGOs;
205 |
206 | static bool _initialized = false;
207 | public static bool Initialized { get { return _initialized; } private set { _initialized = value; } }
208 |
209 | public static void Initialize()
210 | {
211 | AllDynamicGOs = new List();
212 | EventManager.Instance.AddListener(OnBeforeExecuteEvent);
213 | Initialized = true;
214 | }
215 |
216 | public static void Disable()
217 | {
218 | AllDynamicGOs.Clear();
219 | AllDynamicGOs = null;
220 | EventManager.Instance.RemoveListener(OnBeforeExecuteEvent);
221 | Initialized = false;
222 | }
223 |
224 | static void OnBeforeExecuteEvent(BeforeExecutionEvent ev)
225 | {
226 | DestroyAllDynamicGOs();
227 | }
228 |
229 | public static void DestroyAllDynamicGOs()
230 | {
231 | if (GameObjectWatcher.Initialized && AllDynamicGOs.Count != 0)
232 | {
233 |
234 | foreach (GameObject go in AllDynamicGOs)
235 | {
236 | GameObject.Destroy(go);
237 | }
238 |
239 | AllDynamicGOs.Clear();
240 | }
241 | }
242 | }
243 | }
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scripts/GUI/CSScriptInterpreterView.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 50e2244197def6b4182ed6bd0ab54a91
3 | timeCreated: 1460880174
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scripts/GUI/ClassNameButton.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using UCompile;
4 |
5 | namespace ExampleProjectGUI
6 | {
7 |
8 | public class ClassNameButton : MonoBehaviour
9 | {
10 |
11 | public string TypeID { get; set; }
12 | public string TypeCode { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scripts/GUI/ClassNameButton.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: af81f11980c7e8c4692fae4d9b91525d
3 | timeCreated: 1460879815
4 | licenseType: Free
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Assets/UCompile/ExampleProject/Scripts/GUI/ConsoleWindowPanel.cs:
--------------------------------------------------------------------------------
1 | using UCompile;
2 | using UnityEngine;
3 | using UnityEngine.UI;
4 | using WhitelistAPI;
5 |
6 | namespace ExampleProjectGUI
7 | {
8 |
9 | public class ConsoleWindowPanel : MonoBehaviour
10 | {
11 | //All elements of this panel
12 | public GameObject ConsoleWindow;
13 | public GameObject CompileButton;
14 | public GameObject ExecuteButton;
15 | public GameObject OutputWindow;
16 | public GameObject AnimationToggle;
17 | public GameObject CodeToggle;
18 |
19 | InputField _consoleWindow;
20 | Button _compileButton;
21 | Button _executeButton;
22 | Toggle _animationToggle;
23 | Toggle _codeToggle;
24 |
25 | void Awake()
26 | {
27 | _consoleWindow = ConsoleWindow.GetComponent();
28 | _compileButton = CompileButton.GetComponent