public string[] GetScenePathsForWorker(WorkerPlatform workerType)
 {
     return(GetScenesForWorker(workerType)
            .Where(sceneAsset => sceneAsset != null)
            .Select(AssetDatabase.GetAssetPath)
            .ToArray());
 }
        public override void OnInspectorGUI()
        {
            var workerConfiguration = (SpatialOSBuildConfiguration)target;

            EditorGUILayout.BeginHorizontal();
            workerTypeName = EditorGUILayout.TextField(workerTypeName);
            var controlRect = EditorGUILayout.GetControlRect(false);
            var buttonRect  = new Rect(controlRect);

            buttonRect.width = buttonRect.height + 5;

            if (GUI.Button(buttonRect, AddWorkerTypeButtonContents))
            {
                var workerType = new WorkerPlatform(workerTypeName);
                var exists     = workerConfiguration.WorkerBuildConfigurations.Any(x => x.WorkerPlatform == workerType);
                if (!exists)
                {
                    var config = new WorkerBuildConfiguration
                    {
                        WorkerPlatform   = new WorkerPlatform(workerTypeName),
                        ScenesForWorker  = new SceneAsset[] { },
                        LocalBuildConfig = new BuildEnvironmentConfig()
                        {
                            BuildPlatforms = SpatialBuildPlatforms.Current,
                            BuildOptions   = BuildOptions.Development
                        },
                        CloudBuildConfig = new BuildEnvironmentConfig()
                        {
                            BuildPlatforms = SpatialBuildPlatforms.Current
                        }
                    };
                    workerConfiguration.WorkerBuildConfigurations.Add(config);
                }
            }

            EditorGUILayout.EndHorizontal();

            scenesChanged = false;

            var configs = workerConfiguration.WorkerBuildConfigurations;

            foreach (var workerConfig in configs)
            {
                if (!DrawWorkerConfiguration(workerConfig))
                {
                    configs.Remove(workerConfig);
                    break;
                }
            }

            if (scenesChanged)
            {
                scenesChanged = false;
                workerConfiguration.UpdateEditorScenesForBuild();
            }
        }
Example #3
0
        public WorkerBuildData(WorkerPlatform workerPlatform, BuildTarget buildTarget)
        {
            if (!BuildTargetNames.ContainsKey(buildTarget))
            {
                throw new ArgumentException("Unsupported BuildPlatform " + buildTarget);
            }

            this.workerPlatform = workerPlatform;
            this.buildTarget    = buildTarget;
        }
        public BuildEnvironmentConfig GetEnvironmentConfigForWorker(WorkerPlatform platform,
                                                                    BuildEnvironment targetEnvironment)
        {
            var config = WorkerBuildConfigurations.FirstOrDefault(x => x.WorkerPlatform == platform);

            if (config == null)
            {
                throw new ArgumentException("Unknown WorkerPlatform " + platform);
            }

            return(config.GetEnvironmentConfig(targetEnvironment));
        }
        private SceneAsset[] GetScenesForWorker(WorkerPlatform workerPlatform)
        {
            WorkerBuildConfiguration configurationForWorker = null;

            if (WorkerBuildConfigurations != null)
            {
                configurationForWorker =
                    WorkerBuildConfigurations.FirstOrDefault(config => config.WorkerPlatform == workerPlatform);
            }

            return(configurationForWorker == null
                ? new SceneAsset[0]
                : configurationForWorker.ScenesForWorker);
        }