From 4ddfdbbed203461240ca8d970db820e135e804bc Mon Sep 17 00:00:00 2001 From: GotoFinal Date: Tue, 23 Jun 2020 19:17:27 +0200 Subject: [PATCH] GUI cleanup, fix join button and normalize instance id for local testing --- .../ClientManager/ClientManagerEditor.cs | 54 +++++++++++-------- .../Editor/ClientManager/ClientsManager.cs | 13 ++--- Assets/GotoUdon/Editor/GotoUdonEditor.cs | 2 +- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/Assets/GotoUdon/Editor/ClientManager/ClientManagerEditor.cs b/Assets/GotoUdon/Editor/ClientManager/ClientManagerEditor.cs index 0bac9c2..013eb51 100644 --- a/Assets/GotoUdon/Editor/ClientManager/ClientManagerEditor.cs +++ b/Assets/GotoUdon/Editor/ClientManager/ClientManagerEditor.cs @@ -66,6 +66,8 @@ private void OnGUI() _settings.localLaunchOptions = EditorGUILayout.TextField("Local launch options", _settings.localLaunchOptions); // _settings.sendInvitesOnUpdate = EditorGUILayout.Toggle("Send invites on world update", _settings.sendInvitesOnUpdate); _settings.accessType = (ApiWorldInstance.AccessType) EditorGUILayout.EnumPopup("Access Type", _settings.accessType); + _keepInstanceForce = EditorGUILayout.Toggle("Force keep instance ID", _keepInstanceForce); + if (_keepInstanceForce) _keepInstance = true; GUILayout.BeginHorizontal(); GUILayout.Label("Same room restart wait time (s)", GUILayout.Width(200)); @@ -112,23 +114,28 @@ private void DrawClientSection() return; } - _keepInstance = EditorGUILayout.Toggle("Keep current instance ID", _keepInstance); - _keepInstanceForce = EditorGUILayout.Toggle("Force keep instance ID", _keepInstanceForce); - if (_keepInstanceForce) _keepInstance = true; + if (!_localTesting) + { + _keepInstance = EditorGUILayout.Toggle("Keep current instance ID", _keepInstance); + } + _localTesting = EditorGUILayout.Toggle("Use local testing", _localTesting); _clientsManager.InstanceId = EditorGUILayout.TextField(_clientsManager.InstanceId); GUILayout.BeginHorizontal(); - SimpleGUI.ActionButton("Start", () => _clientsManager.StartClients(false, _keepInstance, _localTesting, _keepInstanceForce)); + string startButtonText = _localTesting ? "Start last version (no build)" : "Start"; + SimpleGUI.ActionButton(startButtonText, + () => _clientsManager.StartClients(false, _keepInstance, _localTesting, _keepInstanceForce)); if (_clientsManager.IsAnyClientRunning()) - SimpleGUI.ActionButton("Restart", () => _clientsManager.StartClients(true, _keepInstance, _localTesting, _keepInstanceForce)); + SimpleGUI.ActionButton("Restart", + () => _clientsManager.StartClients(true, _keepInstance, _localTesting, _keepInstanceForce)); GUILayout.EndHorizontal(); if (!Application.isPlaying) { if (_localTesting) { - SimpleGUI.ActionButton("Local testing & Start", BuildAndTest); + SimpleGUI.ActionButton("Build & Start", BuildAndTest); } else { @@ -222,8 +229,12 @@ private bool DrawClientSettings(ClientSettings settings, string buttonAction) EditorGUILayout.BeginHorizontal(); GUILayout.Label("Profile", GUILayout.Width(45)); settings.profile = EditorGUILayout.IntField(settings.profile, GUILayout.Width(20)); - GUILayout.Label("Num of clients", GUILayout.Width(45)); - settings.duplicates = EditorGUILayout.IntField(settings.duplicates, GUILayout.Width(20)); + if (_localTesting) + { + GUILayout.Label("Num of", GUILayout.Width(45)); + settings.duplicates = EditorGUILayout.IntField(settings.duplicates, GUILayout.Width(20)); + } + GUILayout.Label("Enabled", GUILayout.Width(55)); settings.enabled = EditorGUILayout.Toggle(settings.enabled, GUILayout.Width(15)); EditorGUILayout.EndHorizontal(); @@ -233,29 +244,30 @@ private bool DrawClientSettings(ClientSettings settings, string buttonAction) GUILayout.Label("VR", GUILayout.Width(20)); settings.vr = EditorGUILayout.Toggle(settings.vr, GUILayout.Width(15)); - List clientProcess = GotoUdonInternalState.Instance.GetProcessesByProfile(settings.profile); + List + clientProcess = GotoUdonInternalState.Instance.GetProcessesByProfile(settings.profile); if (clientProcess.Count > 0) { string all = clientProcess.Count > 1 ? " All " + clientProcess.Count : ""; SimpleGUI.ActionButton("Stop" + all, () => clientProcess.ForEach(p => p.StopProcess()), GUILayout.Width(65)); - SimpleGUI.ActionButton("Restart" + all, () => _clientsManager.StartClients(true, _keepInstance, _localTesting, _keepInstanceForce, settings), + SimpleGUI.ActionButton("Restart" + all, + () => _clientsManager.StartClients(true, _keepInstance, _keepInstanceForce, _localTesting, settings), GUILayout.Width(90)); - SimpleGUI.ActionButton("Keep room" + all, () => _clientsManager.StartClients(true, true, _localTesting, _keepInstanceForce, settings), - GUILayout.Width(100)); + if (!_localTesting) + SimpleGUI.ActionButton("Keep room" + all, + () => _clientsManager.StartClients(true, true, _keepInstanceForce, _localTesting, settings), + GUILayout.Width(100)); } + if (_localTesting || clientProcess.Count == 0) { - if (_localTesting) - { - EditorGUILayout.EndHorizontal(); - EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); - } SimpleGUI.ActionButton("Start One", - () => _clientsManager.StartClients(false, _keepInstance, _localTesting, _keepInstanceForce, settings.withDuplicates(1)), + () => _clientsManager.StartClients(false, _keepInstance, _keepInstanceForce, _localTesting, settings.withDuplicates(1)), GUILayout.Width(80)); - SimpleGUI.ActionButton("Start One [keep room]", - () => _clientsManager.StartClients(false, true, _localTesting, _keepInstanceForce, settings.withDuplicates(1)), - GUILayout.Width(140)); + if (!_localTesting) + SimpleGUI.ActionButton("Start One [keep room]", + () => _clientsManager.StartClients(false, true, _keepInstanceForce, _localTesting, settings.withDuplicates(1)), + GUILayout.Width(140)); } bool actionButton = GUILayout.Button(buttonAction, GUILayout.Width(70)); diff --git a/Assets/GotoUdon/Editor/ClientManager/ClientsManager.cs b/Assets/GotoUdon/Editor/ClientManager/ClientsManager.cs index 4b6981b..9f65d75 100644 --- a/Assets/GotoUdon/Editor/ClientManager/ClientsManager.cs +++ b/Assets/GotoUdon/Editor/ClientManager/ClientsManager.cs @@ -7,6 +7,7 @@ using VRC.Core; using Object = UnityEngine.Object; using Random = UnityEngine.Random; +using Tools = VRC.Tools; namespace GotoUdon.Editor.ClientManager { @@ -168,10 +169,10 @@ private string GetOrGenerateInstanceId(bool forceDontValidate, bool keepInstance return InstanceId = CreateNewInstanceId(settings, localTestingAsset); } - if (InstanceId.Split(':')[0] != settings.WorldId) + if (!localTesting && InstanceId.Split(':')[0] != settings.WorldId) { internalState.accessType = settings.accessType.ToString(); - return InstanceId = CreateNewInstanceId(settings, localTestingAsset); + return InstanceId = CreateNewInstanceId(settings, null); } if (localTesting && !InstanceId.Contains(localTestingAsset)) @@ -189,13 +190,13 @@ private string GetOrGenerateInstanceId(bool forceDontValidate, bool keepInstance private string CreateNewInstanceId(ClientManagerSettings settings, String localTestingAsset) { - int instanceIndex = Random.Range(1, 99999); - string accessTags = ApiWorldInstance.BuildAccessTags(settings.accessType, settings.userId); - string id = settings.WorldId + ":" + instanceIndex + accessTags; if (localTestingAsset != null) { - id += "&hidden=true&name=BuildAndRun&url=file:///" + localTestingAsset; + return Tools.GetRandomDigits(10) + "&hidden=true&name=BuildAndRun_GotoUdon&url=file:///" + localTestingAsset; } + int instanceIndex = Random.Range(1, 99999); + string accessTags = ApiWorldInstance.BuildAccessTags(settings.accessType, settings.userId); + string id = settings.WorldId + ":" + instanceIndex + accessTags; return id; } diff --git a/Assets/GotoUdon/Editor/GotoUdonEditor.cs b/Assets/GotoUdon/Editor/GotoUdonEditor.cs index 8e110a6..1f05725 100644 --- a/Assets/GotoUdon/Editor/GotoUdonEditor.cs +++ b/Assets/GotoUdon/Editor/GotoUdonEditor.cs @@ -12,7 +12,7 @@ public class GotoUdonEditor : EditorWindow { - public const string VERSION = "v1.3.0"; + public const string VERSION = "v1.3.1"; public const string ImplementedSDKVersion = "2020.06.16.20.53"; public static string CurrentSDKVersion => VRC.Core.SDKClientUtilities.GetSDKVersionDate();