fix: fix ObfuzSettings::LoadOrCreate failed in some cases.

before-split
walon 2025-05-17 16:46:09 +08:00
parent 1f0d2dab22
commit d59939f3e6
1 changed files with 8 additions and 1 deletions

View File

@ -72,7 +72,14 @@ namespace Obfuz.Settings
var arr = InternalEditorUtility.LoadSerializedFileAndForget(filePath); var arr = InternalEditorUtility.LoadSerializedFileAndForget(filePath);
//Debug.Log($"typeof arr:{arr?.GetType()} arr[0]:{(arr != null && arr.Length > 0 ? arr[0].GetType(): null)}"); //Debug.Log($"typeof arr:{arr?.GetType()} arr[0]:{(arr != null && arr.Length > 0 ? arr[0].GetType(): null)}");
s_Instance = arr != null && arr.Length > 0 ? (ObfuzSettings)arr[0] : (s_Instance ?? CreateInstance<ObfuzSettings>()); if (arr != null && arr.Length > 0 && arr[0] is ObfuzSettings obfuzSettings)
{
s_Instance = obfuzSettings;
}
else
{
s_Instance ??= CreateInstance<ObfuzSettings>();
}
return s_Instance; return s_Instance;
} }