Skip to content

Commit b8efa18

Browse files
committed
PR improvements
1 parent 8d80314 commit b8efa18

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

Runtime/VersionServices.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,32 @@ public struct VersionData
6161
/// </summary>
6262
public static async Task LoadVersionDataAsync()
6363
{
64-
var source = new TaskCompletionSource<TextAsset>();
65-
var request = Resources.LoadAsync<TextAsset>(VersionDataFilename);
64+
try
65+
{
66+
var source = new TaskCompletionSource<TextAsset>();
67+
var request = Resources.LoadAsync<TextAsset>(VersionDataFilename);
68+
69+
request.completed += operation => source.SetResult(request.asset as TextAsset);
70+
71+
var textAsset = await source.Task;
6672

67-
request.completed += operation => source.SetResult(request.asset as TextAsset);
73+
if (!textAsset)
74+
{
75+
Debug.LogError("Could not async load version data from Resources.");
76+
_loaded = false;
77+
return;
78+
}
6879

69-
var textAsset = await source.Task;
80+
_versionData = JsonUtility.FromJson<VersionData>(textAsset.text);
81+
_loaded = true;
7082

71-
if (!textAsset)
83+
Resources.UnloadAsset(textAsset);
84+
}
85+
catch (Exception e)
7286
{
73-
Debug.LogError("Could not async load version data from Resources.");
87+
Debug.LogError($"Error loading version data: {e.Message}");
7488
_loaded = false;
75-
return;
7689
}
77-
78-
_versionData = JsonUtility.FromJson<VersionData>(textAsset.text);
79-
_loaded = true;
80-
81-
Resources.UnloadAsset(textAsset);
8290
}
8391

8492
/// <summary>

0 commit comments

Comments
 (0)