Ejemplo n.º 1
0
        private static void BuildWorkerForTarget(string workerType, BuildTarget buildTarget,
                                                 BuildOptions buildOptions, BuildEnvironment targetEnvironment)
        {
            Debug.Log($"Building \"{buildTarget}\" for worker platform: \"{workerType}\", environment: \"{targetEnvironment}\"");

            var spatialOSBuildConfiguration = SpatialOSBuildConfiguration.GetInstance();
            var workerBuildData             = new WorkerBuildData(workerType, buildTarget);
            var scenes = spatialOSBuildConfiguration.GetScenePathsForWorker(workerType);

            var buildPlayerOptions = new BuildPlayerOptions
            {
                options          = buildOptions,
                target           = buildTarget,
                scenes           = scenes,
                locationPathName = workerBuildData.BuildScratchDirectory
            };

            var result = BuildPipeline.BuildPlayer(buildPlayerOptions);

            if (result.summary.result != BuildResult.Succeeded)
            {
                throw new BuildFailedException($"Build failed for {workerType}");
            }

            if (buildTarget == BuildTarget.Android || buildTarget == BuildTarget.iOS)
            {
                // Mobile clients can only be run locally, no need to package them
                return;
            }

            var zipPath  = Path.Combine(PlayerBuildDirectory, workerBuildData.PackageName);
            var basePath = Path.Combine(EditorPaths.BuildScratchDirectory, workerBuildData.PackageName);

            Zip(zipPath, basePath, targetEnvironment == BuildEnvironment.Cloud);
        }
Ejemplo n.º 2
0
        public static void BuildCloudAll()
        {
            var platforms = SpatialOSBuildConfiguration.GetInstance().WorkerBuildConfigurations
                            .Select((x) => x.WorkerPlatform).ToArray();

            MenuBuild(platforms, BuildEnvironment.Cloud);
        }
        /// <returns>An instance of SpatialOSBuildConfiguration if one exists.</returns>
        /// <exception cref="Exception">If no assets exist of type SpatialOSBuildConfiguration</exception>
        private static SpatialOSBuildConfiguration GetBuildConfiguration()
        {
            var spatialOSBuildConfiguration = SpatialOSBuildConfiguration.GetInstance();

            if (spatialOSBuildConfiguration == null)
            {
                throw new Exception(BuildConfigurationMissingErrorMessage);
            }

            return(spatialOSBuildConfiguration);
        }
Ejemplo n.º 4
0
        public static BuildTarget[] GetBuildTargetsForWorkerForEnvironment(string workerType, BuildEnvironment targetEnvironment)
        {
            var environmentConfig = SpatialOSBuildConfiguration.GetInstance().GetEnvironmentConfigForWorker(workerType, targetEnvironment);

            if (environmentConfig == null)
            {
                return(new BuildTarget[0]);
            }

            return(GetUnityBuildTargets(environmentConfig.BuildPlatforms));
        }
Ejemplo n.º 5
0
        public static void BuildWorkerForEnvironment(string workerType, BuildEnvironment targetEnvironment)
        {
            var spatialOSBuildConfiguration = SpatialOSBuildConfiguration.GetInstance();
            var environmentConfig           = spatialOSBuildConfiguration.GetEnvironmentConfigForWorker(workerType, targetEnvironment);
            var buildPlatforms = environmentConfig.BuildPlatforms;
            var buildOptions   = environmentConfig.BuildOptions;

            if (!Directory.Exists(PlayerBuildDirectory))
            {
                Directory.CreateDirectory(PlayerBuildDirectory);
            }

            foreach (var unityBuildTarget in GetUnityBuildTargets(buildPlatforms))
            {
                BuildWorkerForTarget(workerType, unityBuildTarget, buildOptions, targetEnvironment);
            }
        }
Ejemplo n.º 6
0
        public static void BuildWorkerForEnvironment(string workerType, BuildEnvironment targetEnvironment,
                                                     ScriptingImplementation?scriptingBackend = null)
        {
            var spatialOSBuildConfiguration = SpatialOSBuildConfiguration.GetInstance();
            var environmentConfig           =
                spatialOSBuildConfiguration.GetEnvironmentConfigForWorker(workerType, targetEnvironment);

            if (environmentConfig == null)
            {
                Debug.LogWarning($"Skipping build for {workerType}.");
                return;
            }

            var buildPlatforms = environmentConfig.BuildPlatforms;
            var buildOptions   = environmentConfig.BuildOptions;

            if (!Directory.Exists(PlayerBuildDirectory))
            {
                Directory.CreateDirectory(PlayerBuildDirectory);
            }

            foreach (var unityBuildTarget in GetUnityBuildTargets(buildPlatforms))
            {
                var buildTargetGroup       = BuildPipeline.GetBuildTargetGroup(unityBuildTarget);
                var activeScriptingBackend = PlayerSettings.GetScriptingBackend(buildTargetGroup);
                try
                {
                    if (scriptingBackend != null)
                    {
                        Debug.Log($"Setting scripting backend to {scriptingBackend.Value}");
                        PlayerSettings.SetScriptingBackend(buildTargetGroup, scriptingBackend.Value);
                    }

                    BuildWorkerForTarget(workerType, unityBuildTarget, buildOptions, targetEnvironment);
                }
                catch (Exception e)
                {
                    throw new BuildFailedException(e);
                }
                finally
                {
                    PlayerSettings.SetScriptingBackend(buildTargetGroup, activeScriptingBackend);
                }
            }
        }