コード例 #1
0
        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
        }
コード例 #2
0
        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()));
        }
コード例 #3
0
        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)));
        }
コード例 #4
0
        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)));
        }
コード例 #5
0
 protected override RunResult OnRun(RunContext context) => context.Failure(nameof(TestBuildPipelineCantRun));
コード例 #6
0
            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)));
            }