private void Start() { onStartingServerPanel.gameObject.SetActive(false); //First, clear the maps dropdown mapsDropdown.ClearOptions(); //Then get all online scenes onlineTCScenes = TCScenesManager.GetAllOnlineScenes().ToList(); //And all the scenes to the map dropdown List <string> scenes = onlineTCScenes.Select(scene => scene.DisplayNameLocalized).ToList(); mapsDropdown.AddOptions(scenes); mapsDropdown.RefreshShownValue(); //Get active network manager netManager = TCNetworkManager.Instance; //Get the images that are in the input fields gameNameImage = gameNameText.GetComponent <Image>(); //Get the existing colors of the input fields gameNameImageColor = gameNameImage.color; maxPlayersImageColor = maxPlayersImage.color; menuController = GetComponentInParent <MenuController>(); string[] names = Enum.GetNames(typeof(UserProvider)); authModeDropdown.ClearOptions(); authModeDropdown.AddOptions(names.ToList()); authModeDropdown.RefreshShownValue(); }
private static void ListAllEnabledScenes() { Debug.Log($"Online {nameof(TCScene)}s found:"); foreach (TCScene tcScene in TCScenesManager.GetAllOnlineScenes()) { Debug.Log($"{tcScene.scene} ({tcScene.SceneFileName})"); } }
private static void OnDraw() { EditorGUILayout.BeginVertical(GUIStyles.DropdownContentStyle); Color defaultGUIBackgroundColor = GUI.backgroundColor; GUILayout.Label("Quick Start", GUIStyles.DropdownHeaderStyle); string tcFolder = $"{GameBuilder.GetBuildDirectory()}/Team-Capture-Quick/"; #if UNITY_EDITOR_WIN const string appName = "Team-Capture.exe"; #else const string appName = "Team-Capture"; #endif string tcFullPath = $"{tcFolder}{appName}"; if (!File.Exists(tcFullPath)) { EditorGUILayout.HelpBox("You need to build Team-Capture first before being able to use quick start!", MessageType.Error); } else { //Get all TC scenes IReadOnlyList <TCScene> scenes = TCScenesManager.GetAllOnlineScenes(); EditorGUILayout.BeginHorizontal(); { GUI.backgroundColor = Color.green; if (GUILayout.Button("Start")) { //Start each process for (int i = 0; i < quickstartData.entries.Count; i++) { QuickStartEntry entry = quickstartData.entries[i]; //Build arguments string arguments = $"-scene {scenes[quickstartData.selectedSceneIndex].SceneFileName} -auth-method {quickstartData.authMode.ToString()} "; if (entry.server) { arguments += "-batchmode -nographics "; } arguments += entry.additionalArguments; #if UNITY_EDITOR_LINUX if (entry.server) { ProcessHelper.LaunchLinuxTerminalAndLaunchProcess(tcFullPath, arguments); continue; } #endif //Setup and start the process Process newProcess = new Process { StartInfo = new ProcessStartInfo(tcFullPath, arguments) }; newProcess.Start(); StartedProcesses.Add(newProcess); Thread.Sleep(200); } Debug.Log(quickstartData.entries.Count > 1 ? $"Started {quickstartData.entries.Count} processes..." : "Started 1 process..."); } GUI.backgroundColor = defaultGUIBackgroundColor; GUI.backgroundColor = Color.red; if (GUILayout.Button("Stop All")) { //Kill each started process for (int i = 0; i < StartedProcesses.Count; i++) { Process process = StartedProcesses[i]; if (process.HasExited) { continue; } process.Kill(); } StartedProcesses.Clear(); Debug.Log("Stopped processes."); } GUI.backgroundColor = defaultGUIBackgroundColor; } EditorGUILayout.EndHorizontal(); //Make sure there are online scenes if (scenes.Count == 0) { EditorGUILayout.HelpBox("There are no available scenes!", MessageType.Error); } else { //Check that all scenes still exist if (quickstartData.selectedSceneIndex > scenes.Count) { quickstartData.selectedSceneIndex = 0; } //Display the scenes in a popup (aka a dropdown) string[] names = scenes.Select(scene => scene.SceneFileName).ToArray(); quickstartData.selectedSceneIndex = EditorGUILayout.Popup("Scene", quickstartData.selectedSceneIndex, names); } quickstartData.authMode = (UserProvider)EditorGUILayout.EnumPopup("Auth-Mode", quickstartData.authMode); GUILayout.Space(10f); GUILayout.Label("Processes", GUIStyles.DropdownHeaderStyle); if (quickstartData.entries.Count == 0) { EditorGUILayout.HelpBox("There are no processes!", MessageType.Error); } else { for (int i = 0; i < quickstartData.entries.Count; i++) { QuickStartEntry entry = quickstartData.entries[i]; GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.Space(10); entry.server = EditorGUILayout.Toggle("Server?", entry.server); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Space(10); entry.additionalArguments = EditorGUILayout.TextField("Additional Arguments", entry.additionalArguments); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Space(10); if (GUILayout.Button("Remove", new GUIStyle(EditorStyles.miniButtonMid))) { quickstartData.entries.RemoveAt(i); } } GUILayout.EndHorizontal(); GUILayout.Space(8f); } GUILayout.EndVertical(); } } if (GUILayout.Button("Add Process")) { quickstartData.entries.Add(new QuickStartEntry { additionalArguments = string.Empty }); } if (EditorGUI.EndChangeCheck()) { string json = JsonUtility.ToJson(quickstartData); EditorPrefs.SetString(QuickStartDataKey, json); } } EditorGUILayout.EndVertical(); }