protected override RunResult OnRun(RunContext context) { AndroidClassicPipelineShared.SetupPlayerConnection(context); #if UNITY_ANDROID var artifact = context.GetBuildArtifact <AndroidArtifact>(); var fileName = artifact.OutputTargetFile.FullName; if (Path.GetExtension(fileName) != ".apk") { return(context.Failure($"Expected .apk in path, but got '{fileName}'.")); } var path = $"\"{Path.GetFullPath(fileName)}\""; var adb = ADB.GetInstance(); try { EditorUtility.DisplayProgressBar("Installing", $"Installing {path}", 0.3f); adb.Run(new[] { "install", "-r", "-d", path }, $"Failed to install '{fileName}'"); } catch (Exception ex) { return(context.Failure(ex)); } finally { EditorUtility.ClearProgressBar(); } UnityEngine.Debug.Log($"{path} successfully installed."); var applicationIdentifier = context.GetComponentOrDefault <ApplicationIdentifier>(); var runTarget = $"\"{applicationIdentifier.PackageName}/com.unity3d.player.UnityPlayerActivity\""; try { EditorUtility.DisplayProgressBar("Launching", $"Launching {runTarget}", 0.6f); adb.Run(new[] { "shell", "am", "start", "-a", "android.intent.action.MAIN", "-c", "android.intent.category.LAUNCHER", "-f", "0x10200000", "-S", "-n", runTarget }, $"Failed to launch {runTarget}"); } catch (Exception ex) { return(context.Failure(ex)); } finally { EditorUtility.ClearProgressBar(); } UnityEngine.Debug.Log($"{runTarget} successfully launched."); return(context.Success(new AndroidRunInstance())); #else return(context.Failure("Active Editor platform has to be set to Android.")); #endif }
protected override RunResult OnRun(RunContext context) { var artifact = context.GetBuildArtifact <DotsRuntimeBuildArtifact>(); var profile = context.GetComponentOrDefault <DotsRuntimeBuildProfile>(); if (!profile.Target.Run(artifact.OutputTargetFile)) { return(context.Failure($"Failed to start build target {profile.Target.DisplayName} at '{artifact.OutputTargetFile.FullName}'.")); } //@TODO: BuildTarget.Run should return the process, so we can store it in DotsRuntimeRunInstance return(context.Success(new DotsRuntimeRunInstance())); }
protected override RunResult OnRun(RunContext context) { var result = context.GetBuildResult(); Assert.That(result, Is.Not.Null); Assert.That(result.Succeeded, Is.True); var artifact = context.GetBuildArtifact <TestBuildArtifactA>(); Assert.That(artifact, Is.Not.Null); Assert.Throws <NotSupportedException>(() => context.SetValue <TestBuildArtifactB>()); Assert.Throws <NotSupportedException>(() => context.RemoveValue <TestBuildArtifactB>()); return(result.Succeeded && artifact != null?context.Success(new TestRunInstance()) : context.Failure(nameof(artifact))); }
public static RunResult Create(RunContext context) { var artifact = context.GetBuildArtifact <WindowsArtifact>(); var process = new Process(); process.StartInfo.FileName = artifact.OutputTargetFile.FullName; process.StartInfo.WorkingDirectory = artifact.OutputTargetFile.Directory?.FullName ?? string.Empty; process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = true; if (!process.Start()) { return(context.Failure($"Failed to start process at '{process.StartInfo.FileName}'.")); } return(context.Success(new WindowsRunInstance(process))); }
protected override BoolResult OnCanRun(RunContext context) { #if UNITY_ANDROID var artifact = context.GetBuildArtifact <AndroidArtifact>(); if (artifact == null) { return(BoolResult.False($"Could not retrieve build artifact '{nameof(AndroidArtifact)}'. Are you exporting a gradle project? Running gradleproject is not supported.")); } if (artifact.OutputTargetFile == null) { return(BoolResult.False($"{nameof(AndroidArtifact.OutputTargetFile)} is null.")); } return(BoolResult.True()); #else return(BoolResult.False("Active Editor platform has to be set to Android.")); #endif }
protected override BoolResult OnCanRun(RunContext context) { var artifact = context.GetBuildArtifact <WindowsArtifact>(); if (artifact == null) { return(BoolResult.False($"Could not retrieve build artifact '{nameof(WindowsArtifact)}'.")); } if (artifact.OutputTargetFile == null) { return(BoolResult.False($"{nameof(WindowsArtifact.OutputTargetFile)} is null.")); } if (!File.Exists(artifact.OutputTargetFile.FullName)) { return(BoolResult.False($"Output target file '{artifact.OutputTargetFile.FullName}' not found.")); } return(BoolResult.True()); }
protected override RunResult OnRun(RunContext context) { var artifact = context.GetBuildArtifact <MacOSArtifact>(); var process = new Process { StartInfo = { FileName = "open", Arguments = '\"' + artifact.OutputTargetFile.FullName.Trim('\"') + '\"', WorkingDirectory = artifact.OutputTargetFile.Directory?.FullName ?? string.Empty, CreateNoWindow = true, UseShellExecute = true } }; if (!process.Start()) { return(context.Failure($"Failed to start process at '{process.StartInfo.FileName}'.")); } return(context.Success(new MacOSRunInstance(process))); }
protected override BoolResult OnCanRun(RunContext context) { var artifact = context.GetBuildArtifact <MacOSArtifact>(); if (artifact == null) { return(BoolResult.False($"Could not retrieve build artifact '{nameof(MacOSArtifact)}'.")); } if (artifact.OutputTargetFile == null) { return(BoolResult.False($"{nameof(MacOSArtifact.OutputTargetFile)} is null.")); } // On macOS, the output target is a .app directory structure if (!Directory.Exists(artifact.OutputTargetFile.FullName)) { return(BoolResult.False($"Output target file '{artifact.OutputTargetFile.FullName}' not found.")); } return(BoolResult.True()); }
protected override BoolResult OnCanRun(RunContext context) { if (!Target.CanRun) { return(BoolResult.False("Run is not supported with current build settings")); } var artifact = context.GetBuildArtifact <DotsRuntimeBuildArtifact>(); if (artifact == null) { return(BoolResult.False($"Could not retrieve build artifact '{nameof(DotsRuntimeBuildArtifact)}'.")); } if (artifact.OutputTargetFile == null) { return(BoolResult.False($"{nameof(DotsRuntimeBuildArtifact.OutputTargetFile)} is null.")); } if (!File.Exists(artifact.OutputTargetFile.FullName) && !Directory.Exists(artifact.OutputTargetFile.FullName)) { return(BoolResult.False($"Output target file '{artifact.OutputTargetFile.FullName}' not found.")); } if (!context.TryGetComponent <DotsRuntimeBuildProfile>(out var profile)) { return(BoolResult.False($"Could not retrieve component '{nameof(DotsRuntimeBuildProfile)}'.")); } if (profile.Target == null) { return(BoolResult.False($"{nameof(DotsRuntimeBuildProfile)} target is null.")); } return(BoolResult.True()); }