Skip to content

Commit

Permalink
GUI cleanup, fix join button and normalize instance id for local testing
Browse files Browse the repository at this point in the history
  • Loading branch information
GotoFinal committed Jun 23, 2020
1 parent 5d72242 commit 4ddfdbb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
54 changes: 33 additions & 21 deletions Assets/GotoUdon/Editor/ClientManager/ClientManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
Expand All @@ -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<GotoUdonInternalState.ClientProcess> clientProcess = GotoUdonInternalState.Instance.GetProcessesByProfile(settings.profile);
List<GotoUdonInternalState.ClientProcess>
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));
Expand Down
13 changes: 7 additions & 6 deletions Assets/GotoUdon/Editor/ClientManager/ClientsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using VRC.Core;
using Object = UnityEngine.Object;
using Random = UnityEngine.Random;
using Tools = VRC.Tools;

namespace GotoUdon.Editor.ClientManager
{
Expand Down Expand Up @@ -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))
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/GotoUdon/Editor/GotoUdonEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 4ddfdbb

Please sign in to comment.