Fix loading SceneReference property in Visual Script

This commit is contained in:
2026-04-24 17:55:07 +02:00
parent 6b3502675a
commit 135110387d
+13 -7
View File
@@ -507,16 +507,22 @@ namespace FlaxEngine.Json
cache.MemoryStream.Initialize(jsonBuffer, jsonLength); cache.MemoryStream.Initialize(jsonBuffer, jsonLength);
cache.Reader.DiscardBufferedData(); cache.Reader.DiscardBufferedData();
var jsonReader = new JsonTextReader(cache.Reader); var jsonReader = new JsonTextReader(cache.Reader);
if (*jsonBuffer != (byte)'{' && input is LocalizedString asLocalizedString) if (*jsonBuffer != (byte)'{')
{ {
// Hack for objects that are serialized into sth different thant "{..}" (eg. LocalizedString can be saved as plain string if not using localization) // Hack for objects that are serialized into sth different thant "{..}" (eg. LocalizedString can be saved as plain string if not using localization)
asLocalizedString.Id = null; if (input is LocalizedString asLocalizedString)
asLocalizedString.Value = jsonReader.ReadAsString(); {
} asLocalizedString.Id = null;
else asLocalizedString.Value = jsonReader.ReadAsString();
{ return;
cache.JsonSerializer.Populate(jsonReader, input); }
if (input is SceneReference)
{
typeof(SceneReference).GetField("ID").SetValue(input, ParseID(jsonReader.ReadAsString()));
return;
}
} }
cache.JsonSerializer.Populate(jsonReader, input);
if (cache.JsonSerializer.CheckAdditionalContent) if (cache.JsonSerializer.CheckAdditionalContent)
{ {
while (jsonReader.Read()) while (jsonReader.Read())