MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / SceneObject

Method SceneObject

Source/Engine/Serialization/JsonWriter.cpp:399–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399void JsonWriter::SceneObject(::SceneObject* obj)
400{
401 StartObject();
402
403 // Serialize prefab instances with diff detection
404 if (obj->HasPrefabLink())
405 {
406 // Load prefab
407 auto prefab = Content::Load<Prefab>(obj->GetPrefabID());
408 if (prefab)
409 {
410 // Request the prefab to be deserialized to the default instance (used for comparison to generate a diff)
411 prefab->GetDefaultInstance();
412
413 // Get prefab object instance from the prefab
414 ::SceneObject* prefabObject;
415 if (prefab->ObjectsCache.TryGet(obj->GetPrefabObjectID(), prefabObject))
416 {
417 // Serialize modified properties compared with the default object from prefab
418 obj->Serialize(*this, prefabObject);
419 EndObject();
420 return;
421 }
422 else
423 {
424 LOG(Warning, "Missing object {1} in prefab {0}.", prefab->ToString(), obj->GetPrefabObjectID());
425 }
426 }
427 else
428 {
429 LOG(Warning, "Missing prefab {0}.", obj->GetPrefabID());
430 }
431 }
432
433 // Serialize modified properties compared with the default class object
434 const void* defaultInstance = obj->GetType().GetDefaultInstance();
435 obj->Serialize(*this, defaultInstance);
436
437 EndObject();
438}

Callers

nothing calls this directly

Calls 5

GetDefaultInstanceMethod · 0.45
TryGetMethod · 0.45
SerializeMethod · 0.45
ToStringMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected