Skip to content

Commit a7779d7

Browse files
committed
reset on null or whitespaces only now
1 parent 88afe8f commit a7779d7

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

Basis/Packages/com.basis.framework/Players/Common/BasisPlayerSettingsManager.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Concurrent;
23
using System.IO;
34
using System.Threading;
@@ -54,10 +55,20 @@ public static async Task<BasisPlayerSettingsData> RequestPlayerSettings(string u
5455
else
5556
{
5657
var json = await File.ReadAllTextAsync(path);
57-
data = JsonUtility.FromJson<BasisPlayerSettingsData>(json);
5858

59-
// Version==0 after deserialize signals a zero-initialised struct —
60-
// either the JSON was empty/corrupt or predates the Version field.
59+
data = default;
60+
if (!string.IsNullOrWhiteSpace(json))
61+
{
62+
try
63+
{
64+
data = JsonUtility.FromJson<BasisPlayerSettingsData>(json);
65+
}
66+
catch (Exception e)
67+
{
68+
BasisDebug.LogWarning($"Player settings at {path} were unreadable ({e.Message}); resetting to defaults.");
69+
}
70+
}
71+
6172
if (data.Version == 0)
6273
{
6374
data = CreateDefaults(uuid);

0 commit comments

Comments
 (0)