示例#1
0
        private void DrawEnvironmentInspectorForWorker(WorkerBuildConfiguration configurationForWorker)
        {
            EditorGUILayout.LabelField("Environments", EditorStyles.boldLabel);

            DrawEnvironmentInspector(BuildEnvironment.Local, configurationForWorker);
            DrawEnvironmentInspector(BuildEnvironment.Cloud, configurationForWorker);
        }
示例#2
0
        private bool DrawWorkerConfiguration(WorkerBuildConfiguration configurationForWorker)
        {
            var platformName = configurationForWorker.WorkerPlatform.ToString();

            EditorGUILayout.BeginHorizontal();
            configurationForWorker.ShowFoldout =
                EditorGUILayout.Foldout(configurationForWorker.ShowFoldout, platformName);

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

            buttonRect.width = buttonRect.height + 5;
            if (GUI.Button(buttonRect, RemoveWorkerTypeButtonContents))
            {
                return(false);
            }

            EditorGUILayout.EndHorizontal();

            if (configurationForWorker.ShowFoldout)
            {
                using (IndentLevelScope(1))
                {
                    DrawScenesInspectorForWorker(configurationForWorker);
                    DrawEnvironmentInspectorForWorker(configurationForWorker);
                }
            }

            return(true);
        }
示例#3
0
        private void DrawScenesInspectorForWorker(WorkerBuildConfiguration configurationForWorker)
        {
            EditorGUILayout.LabelField("Scenes", EditorStyles.boldLabel);

            using (IndentLevelScope(1))
            {
                var scenesToShowInList = configurationForWorker
                                         .ScenesForWorker
                                         .Select((sceneAsset, index) =>
                                                 new SceneItem(sceneAsset, true, scenesInAssetDatabase))
                                         .ToList();

                EditorGUI.BeginChangeCheck();

                var sceneItems = scenesInAssetDatabase
                                 .Where(sceneAsset => !configurationForWorker.ScenesForWorker.Contains(sceneAsset))
                                 .Select(sceneAsset => new SceneItem(sceneAsset, false, scenesInAssetDatabase))
                                 .ToList();

                var horizontalLayout = Screen.width > ScreenWidthForHorizontalLayout;

                using (horizontalLayout ? new EditorGUILayout.HorizontalScope() : null)
                {
                    using (horizontalLayout ? new EditorGUILayout.VerticalScope() : null)
                    {
                        EditorGUILayout.LabelField("Scenes to include (in order)");

                        DrawIndentedList(scenesToShowInList,
                                         ReorderableListFlags.ShowIndices | ReorderableListFlags.EnableReordering,
                                         SceneItem.Drawer);
                    }

                    using (horizontalLayout ? new EditorGUILayout.VerticalScope() : null)
                    {
                        using (horizontalLayout ? IndentLevelScope(-EditorGUI.indentLevel) : null)
                        {
                            EditorGUILayout.LabelField("Exclude");

                            DrawIndentedList(sceneItems,
                                             ReorderableListFlags.None,
                                             SceneItem.Drawer);
                        }
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(target);
                    Undo.RecordObject(target, "Configure scenes for worker");

                    configurationForWorker.ScenesForWorker = scenesToShowInList.Concat(sceneItems)
                                                             .Where(item => item.Included)
                                                             .Select(item => item.SceneAsset)
                                                             .ToArray();

                    scenesChanged = true;
                }
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
        private void DrawEnvironmentInspector(BuildEnvironment environment,
                                              WorkerBuildConfiguration configurationForWorker)
        {
            using (IndentLevelScope(1))
            {
                EditorGUILayout.LabelField(environment.ToString());

                var environmentConfiguration =
                    configurationForWorker.GetEnvironmentConfig(environment);

                ConfigureBuildPlatforms(environmentConfiguration);
                ConfigureBuildOptions(environmentConfiguration);
            }
        }
        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);
        }
        private void ResetToDefault()
        {
            // Build default settings
            var client = new WorkerBuildConfiguration()
            {
                WorkerPlatform  = WorkerPlatform.UnityClient,
                ScenesForWorker = AssetDatabase.FindAssets("t:Scene")
                                  .Select(AssetDatabase.GUIDToAssetPath)
                                  .Where(path => path.Contains(WorkerPlatform.UnityClient.ToString()))
                                  .Select(AssetDatabase.LoadAssetAtPath <SceneAsset>).ToArray(),
                LocalBuildConfig = new BuildEnvironmentConfig()
                {
                    BuildPlatforms = SpatialBuildPlatforms.Current,
                    BuildOptions   = BuildOptions.Development
                },
                CloudBuildConfig = new BuildEnvironmentConfig()
                {
                    BuildPlatforms = SpatialBuildPlatforms.Current
                }
            };

            var worker = new WorkerBuildConfiguration()
            {
                WorkerPlatform  = WorkerPlatform.UnityGameLogic,
                ScenesForWorker = AssetDatabase.FindAssets("t:Scene")
                                  .Select(AssetDatabase.GUIDToAssetPath)
                                  .Where(path => path.Contains(WorkerPlatform.UnityGameLogic.ToString()))
                                  .Select(AssetDatabase.LoadAssetAtPath <SceneAsset>).ToArray(),
                LocalBuildConfig = new BuildEnvironmentConfig()
                {
                    BuildPlatforms = SpatialBuildPlatforms.Current,
                    BuildOptions   = BuildOptions.EnableHeadlessMode
                },
                CloudBuildConfig = new BuildEnvironmentConfig()
                {
                    BuildPlatforms = SpatialBuildPlatforms.Linux,
                    BuildOptions   = BuildOptions.EnableHeadlessMode
                }
            };

            WorkerBuildConfigurations = new List <WorkerBuildConfiguration>
            {
                client,
                worker
            };

            isInitialised = true;
        }