| 397 | } |
| 398 | |
| 399 | void 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 | } |
nothing calls this directly
no test coverage detected