public override IEnumerator Execute(UTContext context) { var theProjectPath = projectPath.EvaluateIn(context); if (!Directory.Exists(theProjectPath)) { throw new UTFailBuildException("Project path " + theProjectPath + " does not exist.", this); } if (UTFileUtils.IsBelow(UTFileUtils.ProjectRoot, theProjectPath)) { throw new UTFailBuildException("You cannot run uTomate externally on the current project. Use the Sub-Plan node if you want to run a plan as part of a plan.", this); } var thePlanName = planName.EvaluateIn(context); var theDebugMode = debugMode.EvaluateIn(context); var theProperties = EvaluateAll(properties, context); StringBuilder sb = new StringBuilder(); foreach (var prop in theProperties) { sb.Append(" -prop ").Append(UTExecutableParam.Quote(prop)); } Process process = new Process(); process.StartInfo.FileName = UTils.GetEditorExecutable(); process.StartInfo.Arguments = "-projectPath " + UTExecutableParam.Quote(theProjectPath) + " -executeMethod UTExternalRunner.RunPlan -plan " + UTExecutableParam.Quote(thePlanName) + " -debugMode " + theDebugMode + sb.ToString(); if (UTPreferences.DebugMode) { process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; process.OutputDataReceived += (sender, args) => UDebug.Log("[Unity]" + args.Data); UDebug.Log("Executing: " + process.StartInfo.FileName + " with arguments " + process.StartInfo.Arguments); } try { if (!process.Start()) { throw new UTFailBuildException("Unable to start Unity3D.", this); } if (UTPreferences.DebugMode) { process.BeginOutputReadLine(); } } catch (Win32Exception e) { throw new UTFailBuildException("Unable to start process " + e.Message, this); } do { yield return(""); if (context.CancelRequested && !process.HasExited) { process.Kill(); break; } } while(!process.HasExited); if (!context.CancelRequested && failOnError.EvaluateIn(context)) { if (process.ExitCode != 0) { throw new UTFailBuildException("Plan " + thePlanName + " failed or was cancelled.", this); } } }