// Use this for initialization void Start() { uiElements = color_creator.uiElements; Toggle toggle = GetComponent <Toggle>(); Color c = uiElements.color_choices[transform.GetSiblingIndex() - 1]; ColorBlock block = toggle.colors; block.highlightedColor = c; block.normalColor = c; block.pressedColor = c; }
public void SetState() { state = transform.parent.GetComponentInParent <ComponentUI>().state; uiElements = transform.parent.GetComponentInParent <ComponentUI>().uiElements; }
private void DrawDeploymentList() { if (listedDeployments.Count == 0) { using (new EditorGUILayout.VerticalScope()) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); GUILayout.Label("Could not find any live deployments."); GUILayout.FlexibleSpace(); } using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); GUILayout.Label("Press the \"Refresh\" button to search again."); GUILayout.FlexibleSpace(); } } } else { // Temporarily change the label width field to allow better spacing in the deployment list screen. var previousWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 250f; for (var index = 0; index < listedDeployments.Count; index++) { var deplInfo = listedDeployments[index]; var foldoutState = stateManager.GetStateObjectOrDefault <bool>(deplInfo.Id.GetHashCode()); using (var check = new EditorGUI.ChangeCheckScope()) using (new EditorGUILayout.HorizontalScope()) { foldoutState = EditorGUILayout.Foldout(foldoutState, new GUIContent(deplInfo.Name), true); if (GUILayout.Button(style.OpenDeploymentButtonContents, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { var host = GetHostForEnvironment(); Application.OpenURL($"{host}/projects/{projectName}/deployments/{deplInfo.Name}/overview/{deplInfo.Id}"); } if (check.changed) { stateManager.SetStateObject(deplInfo.Id.GetHashCode(), foldoutState); } } using (new EditorGUI.IndentLevelScope()) using (new EditorGUILayout.VerticalScope()) { if (foldoutState) { EditorGUILayout.LabelField("Start Time", deplInfo.StartTime.ToString(CultureInfo.CurrentCulture)); EditorGUILayout.LabelField("Region", deplInfo.Region); if (deplInfo.Workers.Count > 0) { EditorGUILayout.LabelField("Connected Workers"); using (new EditorGUI.IndentLevelScope()) { foreach (var workerPair in deplInfo.Workers) { EditorGUILayout.LabelField(workerPair.Key, $"{workerPair.Value}"); } } } if (deplInfo.Tags.Count > 0) { EditorGUILayout.LabelField("Tags"); using (new EditorGUI.IndentLevelScope()) { foreach (var tag in deplInfo.Tags) { EditorGUILayout.LabelField(tag); } } } } CommonUIElements.DrawHorizontalLine(3, style.HorizontalLineColor); } } EditorGUIUtility.labelWidth = previousWidth; } using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); using (new EditorGUI.DisabledScope(manager.IsActive)) { if (GUILayout.Button("Refresh")) { manager.List(projectName); } } } if (listedDeployments.Count > 0) { using (new EditorGUILayout.HorizontalScope()) { selectedListedDeploymentIndex = EditorGUILayout.Popup("Deployment", selectedListedDeploymentIndex, listedDeployments.Select(config => config.Name).ToArray()); using (new EditorGUI.DisabledScope(!IsSelectedValid(listedDeployments, selectedListedDeploymentIndex) || manager.IsActive)) { if (GUILayout.Button("Stop deployment")) { manager.Stop(listedDeployments[selectedListedDeploymentIndex]); } } } } }
private (bool, DeploymentConfig) DrawDeploymentConfig(DeploymentConfig config) { var foldoutState = stateManager.GetStateObjectOrDefault <bool>(config.Deployment.Name.GetHashCode()); var copy = config.DeepCopy(); var errors = copy.GetErrors(); using (var check = new EditorGUI.ChangeCheckScope()) { using (new EditorGUILayout.HorizontalScope()) { foldoutState = EditorGUILayout.Foldout(foldoutState, new GUIContent(config.Deployment.Name), true); GUILayout.FlexibleSpace(); using (new EditorGUIUtility.IconSizeScope(style.SmallIconSize)) { if (errors.Any()) { GUILayout.Label(style.DeploymentConfigurationErrorContents); } if (GUILayout.Button(style.RemoveDeploymentConfigurationButtonContents, EditorStyles.miniButton)) { return(true, null); } } } using (new EditorGUI.IndentLevelScope()) using (new EditorGUILayout.VerticalScope()) { if (foldoutState) { copy.AssemblyName = EditorGUILayout.TextField("Assembly Name", config.AssemblyName); RenderBaseDeploymentConfig(config.Deployment, copy.Deployment); if (copy.Deployment.Name != config.Deployment.Name) { UpdateSimulatedDeploymentNames(copy); } GUILayout.Space(10); EditorGUILayout.LabelField("Simulated Player Deployments"); for (var i = 0; i < copy.SimulatedPlayerDeploymentConfigs.Count; i++) { var simConfig = copy.SimulatedPlayerDeploymentConfigs[i]; var(shouldRemove, updated) = DrawSimulatedConfig(i, simConfig); GUILayout.Space(5); if (shouldRemove) { copy.SimulatedPlayerDeploymentConfigs.RemoveAt(i); i--; UpdateSimulatedDeploymentNames(copy); } else { copy.SimulatedPlayerDeploymentConfigs[i] = updated; } } } } using (new EditorGUILayout.HorizontalScope()) { if (foldoutState) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Add simulated player deployment")) { var newSimPlayerDepl = new SimulatedPlayerDeploymentConfig(); newSimPlayerDepl.TargetDeploymentName = config.Deployment.Name; newSimPlayerDepl.Name = $"{config.Deployment.Name}_sim{config.SimulatedPlayerDeploymentConfigs.Count + 1}"; copy.SimulatedPlayerDeploymentConfigs.Add(newSimPlayerDepl); } } } if (errors.Any()) { EditorGUILayout.HelpBox($"This deployment configuration has the following errors:\n\n{errors.FormatErrors()}", MessageType.Error); } if (check.changed) { stateManager.SetStateObject(copy.Deployment.Name.GetHashCode(), foldoutState); } } CommonUIElements.DrawHorizontalLine(5, style.HorizontalLineColor); return(false, copy); }
private AssemblyConfig DrawAssemblyConfig(AssemblyConfig config) { GUILayout.Label("Assembly Upload", EditorStyles.boldLabel); var copy = config.DeepCopy(); var error = config.GetError(); using (new EditorGUILayout.VerticalScope()) { using (new EditorGUILayout.HorizontalScope()) { copy.AssemblyName = EditorGUILayout.TextField("Assembly Name", config.AssemblyName); if (GUILayout.Button("Generate", GUILayout.ExpandWidth(false))) { copy.AssemblyName = $"{projectName}_{DateTime.Now:MMdd_HHmm}"; GUI.FocusControl(null); } } copy.ShouldForceUpload = EditorGUILayout.Toggle("Force Upload", config.ShouldForceUpload); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); using (new EditorGUILayout.HorizontalScope()) { var shouldBeVertical = EditorGUIUtility.currentViewWidth < 550; /* Responsive Layout, Intuitive API! */ if (shouldBeVertical) { EditorGUILayout.BeginVertical(); } else { GUILayout.FlexibleSpace(); } using (new EditorGUI.DisabledScope(error != null)) { if (GUILayout.Button("Assign assembly name to deployments")) { foreach (var deplConfig in launcherConfig.DeploymentConfigs) { deplConfig.AssemblyName = launcherConfig.AssemblyConfig.AssemblyName; } } using (new EditorGUI.DisabledScope(manager.IsActive)) { if (GUILayout.Button("Upload assembly")) { manager.Upload(config); } } } if (shouldBeVertical) { EditorGUILayout.EndVertical(); } } if (error != null) { EditorGUILayout.HelpBox(error, MessageType.Error); } } CommonUIElements.DrawHorizontalLine(3, style.HorizontalLineColor); return(copy); }
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(); } } }
public void OnGUI() { GUILayout.Label(MobileSectionLabel, EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { launchConfig.RuntimeIp = EditorGUILayout.TextField(RuntimeIpLabel, launchConfig.RuntimeIp); launchConfig.ShouldConnectLocally = EditorGUILayout.Toggle(ConnectLocallyLabel, launchConfig.ShouldConnectLocally); } CommonUIElements.DrawHorizontalLine(10, LightGrey); GUILayout.Label(AndroidSectionLabel, EditorStyles.boldLabel); if (GUILayout.Button("Launch Android app")) { AndroidLaunchUtils.Launch(launchConfig.ShouldConnectLocally, launchConfig.RuntimeIp); } #if UNITY_EDITOR_OSX CommonUIElements.DrawHorizontalLine(10, LightGrey); GUILayout.Label(iOSSectionLabel, EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { launchConfig.DevelopmentTeamId = EditorGUILayout.TextField(DevelopmentTeamIdLabel, launchConfig.DevelopmentTeamId); if (GUILayout.Button("Build XCode project")) { iOSLaunchUtils.Build(launchConfig.DevelopmentTeamId); } CommonUIElements.DrawHorizontalLine(8, DarkGrey); using (new GUILayout.HorizontalScope()) { using (new EditorGUI.DisabledScope(simulatorNames.Length == 0)) { simulatorNameIndex = EditorGUILayout.Popup("Simulator Model", simulatorNameIndex, simulatorNames); } var buttonIcon = new GUIContent(EditorGUIUtility.IconContent("Refresh")) { tooltip = "Refresh your simulator list." }; if (GUILayout.Button(buttonIcon, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { simulatorNames = iOSLaunchUtils.RetrieveAvailableiOSSimulators().Keys.ToArray(); simulatorNameIndex = 0; } } using (new EditorGUI.DisabledScope(simulatorNames.Length == 0)) { if (GUILayout.Button("Launch iOS app in Simulator")) { var availableSimulators = iOSLaunchUtils.RetrieveAvailableiOSSimulators(); if (availableSimulators.TryGetValue(simulatorNames[simulatorNameIndex], out var simulatorUID)) { iOSLaunchUtils.Launch(launchConfig.ShouldConnectLocally, simulatorUID, launchConfig.RuntimeIp, true); } else { simulatorNames = availableSimulators.Keys.ToArray(); simulatorNameIndex = 0; Debug.LogError("Failed to launch app on selected simulator."); } } } CommonUIElements.DrawHorizontalLine(8, DarkGrey); using (new GUILayout.HorizontalScope()) { using (new EditorGUI.DisabledScope(deviceNames.Length == 0)) { deviceNameIndex = EditorGUILayout.Popup("Device Model", deviceNameIndex, deviceNames); } var buttonIcon = new GUIContent(EditorGUIUtility.IconContent("Refresh")) { tooltip = "Refresh your device list." }; if (GUILayout.Button(buttonIcon, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { deviceNames = iOSLaunchUtils.RetrieveAvailableiOSDevices().Keys.ToArray(); deviceNameIndex = 0; } } using (new EditorGUI.DisabledScope(deviceNames.Length == 0)) { if (GUILayout.Button("Launch iOS app on device")) { var availableDevices = iOSLaunchUtils.RetrieveAvailableiOSDevices(); if (availableDevices.TryGetValue(deviceNames[deviceNameIndex], out var deviceUID)) { iOSLaunchUtils.Launch(launchConfig.ShouldConnectLocally, deviceUID, launchConfig.RuntimeIp, false); } else { deviceNames = availableDevices.Keys.ToArray(); deviceNameIndex = 0; Debug.LogError("Failed to launch app on selected device. Is the device still connected?"); } } } } #endif }