Skip to content

Commit 45fcfb9

Browse files
Erik Bylundkirre-bylund
authored andcommitted
fix: Make current flow a state instead of parameter in extension
1 parent ecf7c42 commit 45fcfb9

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

Runtime/Client/LootLockerServerApi.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,19 @@ public static void Instantiate()
5050

5151
public static IEnumerator CleanUpOldInstances()
5252
{
53+
#if UNITY_2020_1_OR_NEWER
5354
LootLockerServerApi[] serverApis = GameObject.FindObjectsByType<LootLockerServerApi>(FindObjectsInactive.Include, FindObjectsSortMode.None);
55+
#else
56+
LootLockerServerApi[] serverApis = GameObject.FindObjectsOfType<LootLockerServerApi>();
57+
#endif
5458
foreach (LootLockerServerApi serverApi in serverApis)
5559
{
5660
if (serverApi != null && _instanceId != serverApi.GetInstanceID() && serverApi.HostingGameObject != null)
5761
{
5862
#if UNITY_EDITOR
5963
DestroyImmediate(serverApi.HostingGameObject);
6064
#else
61-
Destroy(gameObject);
65+
Destroy(serverApi.HostingGameObject);
6266
#endif
6367
}
6468
}

Runtime/Editor/Editor UI/LootLockerAdminExtension.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class LootLockerAdminExtension : EditorWindow
1818
private Label gameName;
1919
DateTime gameDataRefreshTime;
2020
readonly int gameDataCacheExpirationTimeMinutes = 1;
21+
private VisualElement currentFlow = null;
2122

2223
[SerializeField]
2324
private VisualTreeAsset m_VisualTreeAsset = default;
@@ -88,16 +89,16 @@ public static void Run()
8889
{
8990
if (LootLockerEditorData.GetSelectedGame() != 0)
9091
{
91-
wnd.SwapFlows(wnd.loginFlow, wnd.apiKeyFlow);
92+
wnd.SwapFlows(wnd.apiKeyFlow);
9293
return;
9394
}
94-
wnd.SwapFlows(null, wnd.gameSelectorFlow);
95+
wnd.SwapFlows(wnd.gameSelectorFlow);
9596

9697
});
9798
return;
9899
}
99100

100-
wnd.SwapFlows(null, wnd.loginFlow);
101+
wnd.SwapFlows(wnd.loginFlow);
101102
}
102103

103104
[InitializeOnLoadMethod]
@@ -176,7 +177,7 @@ public void CreateGUI()
176177

177178
menuChangeGameBtn.clickable.clicked += () =>
178179
{
179-
SwapFlows(activeFlow, gameSelectorFlow);
180+
SwapFlows(gameSelectorFlow);
180181
};
181182

182183
popup = root.Q<VisualElement>("PopUp");
@@ -197,7 +198,6 @@ public void CreateGUI()
197198

198199
passwordField.RegisterCallback<KeyDownEvent>((evt) =>
199200
{
200-
201201
if (evt.keyCode == KeyCode.Return)
202202
{
203203
Login();
@@ -250,7 +250,6 @@ public void CreateGUI()
250250

251251
newApiKeyCancel.RegisterCallback<MouseDownEvent>(_ =>
252252
{
253-
254253
newApiKeyName.value = "";
255254
newApiKeyWindow.style.display = DisplayStyle.None;
256255

@@ -262,7 +261,6 @@ public void CreateGUI()
262261
{
263262
CreateNewAPIKey();
264263
newApiKeyWindow.style.display = DisplayStyle.None;
265-
266264
};
267265

268266
createNewApiKeyBtn = root.Q<Button>("CreateKeyBtn");
@@ -289,6 +287,7 @@ public void CreateGUI()
289287

290288
loadingPage = root.Q<VisualElement>("LoadingBackground");
291289
loadingPage.style.display = DisplayStyle.Flex;
290+
currentFlow = loadingPage;
292291

293292
loadingIcon = root.Q<VisualElement>("LoadingIcon");
294293

@@ -337,16 +336,16 @@ void SwapEnvironment()
337336
}
338337
}
339338

340-
void SwapFlows(VisualElement old, VisualElement New)
339+
void SwapFlows(VisualElement New)
341340
{
342-
if (old == New) return;
341+
if (currentFlow == New) return;
343342

344343
activeFlow = New;
345344

346-
if (old != null)
345+
if (currentFlow != null)
347346
{
348-
old.style.display = DisplayStyle.None;
349-
if (old == apiKeyFlow)
347+
currentFlow.style.display = DisplayStyle.None;
348+
if (currentFlow == apiKeyFlow)
350349
{
351350
apiKeyList.Clear();
352351
}
@@ -401,6 +400,8 @@ void SwapFlows(VisualElement old, VisualElement New)
401400
menuAPIKeyBtn.style.display = DisplayStyle.None;
402401
menuChangeGameBtn.style.display = DisplayStyle.None;
403402
}
403+
404+
currentFlow = New;
404405
}
405406

406407
private void OnEditorUpdate()
@@ -447,7 +448,7 @@ public void Login()
447448
mfaKey = onComplete.mfa_key;
448449
menu.style.display = DisplayStyle.Flex;
449450
loadingPage.style.display = DisplayStyle.None;
450-
SwapFlows(loginFlow, mfaFlow);
451+
SwapFlows(mfaFlow);
451452
}
452453
else
453454
{
@@ -456,7 +457,7 @@ public void Login()
456457
LootLockerEditorData.SetAdminToken(onComplete.auth_token);
457458
loadingPage.style.display = DisplayStyle.None;
458459

459-
SwapFlows(loginFlow, gameSelectorFlow);
460+
SwapFlows(gameSelectorFlow);
460461
}
461462
menuLogoutBtn.style.display = DisplayStyle.Flex;
462463
EditorApplication.update -= OnEditorUpdate;
@@ -479,7 +480,7 @@ public void SignIn(EventBase e)
479480
LootLockerEditorData.SetAdminToken(onComplete.auth_token);
480481
string projectPrefix = PlayerSettings.productGUID.ToString();
481482

482-
SwapFlows(mfaFlow, gameSelectorFlow);
483+
SwapFlows(gameSelectorFlow);
483484

484485
EditorApplication.update -= OnEditorUpdate;
485486
loadingPage.style.display = DisplayStyle.None;
@@ -620,7 +621,7 @@ void OnGameSelected(EventBase e)
620621

621622

622623

623-
SwapFlows(gameSelectorFlow, apiKeyFlow);
624+
SwapFlows(apiKeyFlow);
624625
}
625626

626627
void CreateNewAPIKey()
@@ -773,7 +774,7 @@ void Logout()
773774
apiKeyList.Clear();
774775
gameSelectorList.Clear();
775776
loadingPage.style.display = DisplayStyle.None;
776-
SwapFlows(activeFlow, loginFlow);
777+
SwapFlows(loginFlow);
777778
}
778779

779780
private void OnDestroy()

0 commit comments

Comments
 (0)