/// <summary> /// Called by Unity. /// </summary> public IEnumerator Start() { // Create domain domain = ScriptDomain.CreateDomain("Example Domain"); // Compile and load code AsyncCompileOperation compileRequest = domain.CompileAndLoadSourceAsync(sourceCode, ScriptSecurityMode.UseSettings); // Wait for operation to complete yield return(compileRequest); // Check for compiler errors if (compileRequest.IsSuccessful == false) { // Get all errors foreach (CompilationError error in compileRequest.CompileDomain.CompileResult.Errors) { if (error.IsError == true) { Debug.LogError(error.ToString()); } else if (error.IsWarning == true) { Debug.LogWarning(error.ToString()); } } } }
public IEnumerator RunAsync(string source, TextMeshProUGUI textUI, List <int> list, List <double> listD) { LoadingCircle.UpdateLoad(true); Debug.Log(source); ScriptDomain domain = ScriptDomain.CreateDomain("resposta"); AsyncCompileOperation compileRequest = domain.CompileAndLoadSourceAsync(source, ScriptSecurityMode.UseSettings); // Wait for operation to complete yield return(compileRequest); // Check for compiler errors if (compileRequest.IsSuccessful == false) { // Get all errors foreach (CompilationError error in compileRequest.CompileDomain.CompileResult.Errors) { if (error.IsError == true) { Debug.LogError(error.ToString()); textUI.text = error.ToString(); } else if (error.IsWarning == true) { Debug.LogWarning(error.ToString()); } } } else { type = compileRequest.CompiledType; proxy = type.CreateInstance(this.gameObject); proxy.Fields["_inputs"] = list; proxy.Fields["_Dinputs"] = listD; proxy.Call(initBlock.name); if ((string)proxy.Fields["_loopError"] != null) { textUI.text = (string)proxy.Fields["_loopError"]; } else { textUI.text = (string)proxy.Fields["_output"]; } } LoadingCircle.UpdateLoad(false); }