示例#1
0
        private void OnEnable()
        {
            launcherConfig = DeploymentLauncherConfig.GetInstance();
            projectName    = GetProjectName();

            if (launcherConfig != null && projectName != null)
            {
                launcherConfig.SetProjectName(projectName);
                MarkConfigAsDirty();
            }

            Application.quitting += OnExit;
        }
        private void OnEnable()
        {
            launcherConfig = DeploymentLauncherConfig.GetInstance();
            projectName    = GetProjectName();

            if (launcherConfig != null && projectName != null)
            {
                launcherConfig.SetProjectName(projectName);
                MarkConfigAsDirty();
            }

            spinnerMaterial = new Material(Shader.Find("UI/Default"));

            Application.quitting += OnExit;
        }
示例#3
0
        private void OnEnable()
        {
            launcherConfig = DeploymentLauncherConfig.GetInstance();
            projectName    = GetProjectName();

            if (launcherConfig != null && projectName != null)
            {
                launcherConfig.SetProjectName(projectName);
                EditorUtility.SetDirty(launcherConfig);
                AssetDatabase.SaveAssets();
            }

            spinnerMaterial = new Material(Shader.Find("UI/Default"));

            Application.quitting += OnExit;
        }
示例#4
0
        private void OnGUI()
        {
            if (style == null)
            {
                style = new DeploymentLauncherWindowStyle();
            }

            if (launcherConfig == null)
            {
                EditorGUILayout.HelpBox($"Could not find a {nameof(DeploymentLauncherConfig)} instance.\nPlease create one via the Assets > Create > SpatialOS menu.", MessageType.Info);
                return;
            }

            if (projectName == null)
            {
                EditorGUILayout.HelpBox("Could not parse your SpatialOS project name. See the Console for more details", MessageType.Error);
                return;
            }

            using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos))
                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        using (new EditorGUI.DisabledScope(manager.IsActive))
                        {
                            if (GUILayout.Button(style.ProjectRefreshButtonContents, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                            {
                                projectName = GetProjectName();
                                launcherConfig.SetProjectName(projectName);
                                MarkConfigAsDirty();
                            }
                        }

                        EditorGUILayout.LabelField("Project Name", projectName);
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        using (new EditorGUI.DisabledScope(manager.IsActive))
                        {
                            if (GUILayout.Button(style.EditRuntimeVersionButtonContents, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                            {
                                GdkToolsConfigurationWindow.ShowWindow();
                            }
                        }

                        var config = GdkToolsConfiguration.GetOrCreateInstance();

                        EditorGUILayout.LabelField("Runtime Version", config.RuntimeVersion);
                    }

                    CommonUIElements.DrawHorizontalLine(5, style.HorizontalLineColor);

                    launcherConfig.AssemblyConfig = DrawAssemblyConfig(launcherConfig.AssemblyConfig);

                    GUILayout.Label("Deployment Configurations", EditorStyles.boldLabel);

                    for (var index = 0; index < launcherConfig.DeploymentConfigs.Count; index++)
                    {
                        var deplConfig = launcherConfig.DeploymentConfigs[index];
                        var(shouldRemove, updated) = DrawDeploymentConfig(deplConfig);
                        if (shouldRemove)
                        {
                            launcherConfig.DeploymentConfigs.RemoveAt(index);
                            index--;
                        }
                        else
                        {
                            launcherConfig.DeploymentConfigs[index] = updated;
                        }
                    }

                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button("Add new deployment configuration"))
                        {
                            var deploymentConfig = new DeploymentConfig
                            {
                                AssemblyName = launcherConfig.AssemblyConfig.AssemblyName,
                                Deployment   = new BaseDeploymentConfig
                                {
                                    Name = $"deployment_{launcherConfig.DeploymentConfigs.Count}"
                                }
                            };

                            launcherConfig.DeploymentConfigs.Add(deploymentConfig);
                        }
                    }

                    if (launcherConfig.DeploymentConfigs.Count > 0)
                    {
                        using (new GUILayout.HorizontalScope())
                        {
                            selectedDeploymentIndex = EditorGUILayout.Popup("Deployment", selectedDeploymentIndex,
                                                                            launcherConfig.DeploymentConfigs.Select(config => config.Deployment.Name).ToArray());

                            var isValid = IsSelectedValid(launcherConfig.DeploymentConfigs, selectedDeploymentIndex);

                            var hasErrors = isValid && launcherConfig.DeploymentConfigs[selectedDeploymentIndex].GetErrors().Any();

                            using (new EditorGUI.DisabledScope(!isValid || hasErrors || manager.IsActive))
                            {
                                if (GUILayout.Button("Launch deployment"))
                                {
                                    var deplConfig = launcherConfig.DeploymentConfigs[selectedDeploymentIndex];

                                    manager.Launch(deplConfig.ProjectName, deplConfig.AssemblyName, deplConfig.Deployment);

                                    foreach (var simPlayerDepl in deplConfig.SimulatedPlayerDeploymentConfigs)
                                    {
                                        manager.Launch(deplConfig.ProjectName, deplConfig.AssemblyName, simPlayerDepl);
                                    }
                                }
                            }
                        }
                    }

                    CommonUIElements.DrawHorizontalLine(5, style.HorizontalLineColor);
                    GUILayout.Label("Live Deployments", EditorStyles.boldLabel);
                    DrawDeploymentList();

                    scrollPos = scrollView.scrollPosition;

                    if (check.changed)
                    {
                        MarkConfigAsDirty();
                    }

                    if (manager.IsActive)
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUILayout.HelpBox(GetStatusMessage(), MessageType.Info);

                            if (!(manager.CurrentTask is AuthTask) &&
                                GUILayout.Button("Cancel", GUILayout.Height(38), GUILayout.Width(75)))
                            {
                                CancelCurrentTask();
                            }
                        }

                        var rect = EditorGUILayout.GetControlRect(false, 20);
                        style.DrawSpinner(Time.realtimeSinceStartup * 10, rect);

                        Repaint();
                    }
                }
        }