Skip to content

Commit d5b941c

Browse files
Mikkel Sørensenkirre-bylund
authored andcommitted
Fix issues with Unity Admin Extension
1 parent cc91630 commit d5b941c

File tree

8 files changed

+92
-4
lines changed

8 files changed

+92
-4
lines changed

Runtime/Client/LootLockerServerRequest.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,16 @@ public static void CallAPI(string endPoint, LootLockerHTTPMethod httpMethod, str
453453
if (useAuthToken)
454454
{
455455
headers = new Dictionary<string, string>();
456-
if (callerRole == LootLocker.LootLockerEnums.LootLockerCallerRole.Admin && !string.IsNullOrEmpty(LootLockerConfig.current.adminToken))
456+
if (callerRole == LootLocker.LootLockerEnums.LootLockerCallerRole.Admin)
457457
{
458-
headers.Add("x-auth-token", LootLockerConfig.current.adminToken);
458+
#if UNITY_EDITOR
459+
if (!string.IsNullOrEmpty(LootLockerConfig.current.adminToken))
460+
{
461+
headers.Add("x-auth-token", LootLockerConfig.current.adminToken);
462+
}
463+
#endif
459464
}
460-
else if (callerRole != LootLocker.LootLockerEnums.LootLockerCallerRole.Admin && !string.IsNullOrEmpty(LootLockerConfig.current.token))
465+
else if (!string.IsNullOrEmpty(LootLockerConfig.current.token))
461466
{
462467
headers.Add("x-session-token", LootLockerConfig.current.token);
463468
}

Runtime/Editor/Icons.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Editor/LootLockerAdminEndPoints.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Editor/LootLockerExtensionCalls.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Editor/LootLockerExtensionResponses.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Editor/Resources.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Editor/StoredUser.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using LootLocker;
22
using LootLocker.Extension.Requests;
33
using System.IO;
4+
using System;
45
using UnityEditor;
56
using UnityEngine;
67

@@ -35,6 +36,39 @@ private void Serialize()
3536
serializedUser = LootLockerJson.SerializeObject(user);
3637
}
3738

39+
[InitializeOnLoadMethod]
40+
private static void FirstLoad()
41+
{
42+
EditorPrefs.DeleteAll();
43+
44+
string projectPath = Application.dataPath;
45+
46+
DateTime creationTime = Directory.GetCreationTime(projectPath);
47+
string configFileEditorPref = "StoredUserCreated" + creationTime.GetHashCode().ToString();
48+
49+
if (EditorPrefs.GetBool(configFileEditorPref) == false)
50+
{
51+
52+
if (Directory.Exists("Packages/com.lootlocker.lootlockersdk"))
53+
{
54+
if (Directory.Exists("Assets/LootLockerSDK/Runtime/Editor/VisualElements"))
55+
{
56+
Directory.Delete("Assets/LootLockerSDK/Runtime/Editor/VisualElements", recursive: true);
57+
}
58+
59+
Directory.CreateDirectory("Assets/LootLockerSDK/Runtime/Editor/VisualElements/LootLocker MainWindow");
60+
61+
FileUtil.CopyFileOrDirectory("Packages/com.lootlocker.lootlockersdk/Runtime/Editor/VisualElements/LootLocker MainWindow/LootLockerMainWindow.uss", "Assets/LootLockerSDK/Runtime/Editor/VisualElements/LootLocker MainWindow/LootLockerMainWindow.uss");
62+
63+
EditorApplication.delayCall += AssetDatabase.SaveAssets;
64+
AssetDatabase.Refresh();
65+
}
66+
67+
EditorPrefs.SetBool(configFileEditorPref, true);
68+
}
69+
70+
}
71+
3872
private static StoredUser Get()
3973
{
4074
if (_current != null)

Runtime/Game/Resources/LootLockerConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ public static LootLockerConfig current
146146
public string apiKey;
147147
[HideInInspector]
148148
public string token;
149-
[HideInInspector]
150149
#if UNITY_EDITOR
150+
[HideInInspector]
151151
public string adminToken;
152152
#endif
153153
[HideInInspector]

0 commit comments

Comments
 (0)