Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fetch config from assets folder first #233

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using NUnit.Framework;
using NUnit.Framework.Internal;
using UnityEditor;
using UnityEngine;
using UnityEngine.Serialization;

Expand Down Expand Up @@ -38,7 +39,12 @@ public static SequenceConfig GetConfig()
{
if (_config == null)
{
_config = Resources.Load<SequenceConfig>("SequenceConfig");
_config = LoadConfig();
if (_config == null)
{
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");
}

TextAsset versionFile = Resources.Load<TextAsset>("sequence-unity-version");
if (versionFile != null)
{
Expand All @@ -54,12 +60,26 @@ public static SequenceConfig GetConfig()
#endif
}

if (_config == null)
return _config;
}

private static SequenceConfig LoadConfig()
{
#if UNITY_EDITOR
string[] guids = AssetDatabase.FindAssets($"SequenceConfig t:{nameof(SequenceConfig)}");
foreach (string guid in guids)
{
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");
string path = AssetDatabase.GUIDToAssetPath(guid);
if (path.StartsWith("Assets"))
{
return AssetDatabase.LoadAssetAtPath<SequenceConfig>(path);
}
}

return _config;
return Resources.Load<SequenceConfig>("SequenceConfig");
#else
return Resources.Load<SequenceConfig>("SequenceConfig");
#endif
}

public static Exception MissingConfigError(string valueName)
Expand Down
2 changes: 1 addition & 1 deletion Packages/Sequence-Unity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xyz.0xsequence.waas-unity",
"version": "3.17.0",
"version": "3.17.1",
"displayName": "Sequence Embedded Wallet SDK",
"description": "A Unity SDK for the Sequence WaaS API",
"unity": "2021.3",
Expand Down
Loading