Skip to content

Commit ab85b96

Browse files
authored
Merge pull request #233 from 0xsequence/Fix/configFetchFromAssets
Attempt to fetch config from assets folder first
2 parents 6f3903c + 495bc18 commit ab85b96

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

Packages/Sequence-Unity/Sequence/SequenceSDK/Config/SequenceConfig.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using NUnit.Framework;
33
using NUnit.Framework.Internal;
4+
using UnityEditor;
45
using UnityEngine;
56
using UnityEngine.Serialization;
67

@@ -38,7 +39,12 @@ public static SequenceConfig GetConfig()
3839
{
3940
if (_config == null)
4041
{
41-
_config = Resources.Load<SequenceConfig>("SequenceConfig");
42+
_config = LoadConfig();
43+
if (_config == null)
44+
{
45+
throw new Exception("SequenceConfig not found. Make sure to create and configure it and place it at the root of your Resources folder. Create it from the top bar with Assets > Create > Sequence > SequenceConfig");
46+
}
47+
4248
TextAsset versionFile = Resources.Load<TextAsset>("sequence-unity-version");
4349
if (versionFile != null)
4450
{
@@ -54,12 +60,26 @@ public static SequenceConfig GetConfig()
5460
#endif
5561
}
5662

57-
if (_config == null)
63+
return _config;
64+
}
65+
66+
private static SequenceConfig LoadConfig()
67+
{
68+
#if UNITY_EDITOR
69+
string[] guids = AssetDatabase.FindAssets($"SequenceConfig t:{nameof(SequenceConfig)}");
70+
foreach (string guid in guids)
5871
{
59-
throw new Exception("SequenceConfig not found. Make sure to create and configure it and place it at the root of your Resources folder. Create it from the top bar with Assets > Create > Sequence > SequenceConfig");
72+
string path = AssetDatabase.GUIDToAssetPath(guid);
73+
if (path.StartsWith("Assets"))
74+
{
75+
return AssetDatabase.LoadAssetAtPath<SequenceConfig>(path);
76+
}
6077
}
6178

62-
return _config;
79+
return Resources.Load<SequenceConfig>("SequenceConfig");
80+
#else
81+
return Resources.Load<SequenceConfig>("SequenceConfig");
82+
#endif
6383
}
6484

6585
public static Exception MissingConfigError(string valueName)

Packages/Sequence-Unity/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xyz.0xsequence.waas-unity",
3-
"version": "3.17.0",
3+
"version": "3.17.1",
44
"displayName": "Sequence Embedded Wallet SDK",
55
"description": "A Unity SDK for the Sequence WaaS API",
66
"unity": "2021.3",

0 commit comments

Comments
 (0)