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

Method UpdateInternal

Source/Engine/Level/Prefabs/Prefab.Apply.cpp:1221–1356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1219}
1220
1221bool Prefab::UpdateInternal(const Array<SceneObject*>& defaultInstanceObjects, rapidjson_flax::StringBuffer& tmpBuffer)
1222{
1223 PROFILE_CPU_NAMED("Prefab.UpdateData");
1224
1225 // Serialize to json data
1226 {
1227 tmpBuffer.Clear();
1228 PrettyJsonWriter writerObj(tmpBuffer);
1229 PrefabInstanceData::SerializeObjects(defaultInstanceObjects, writerObj);
1230 }
1231
1232 LOG(Info, "Updating prefab data");
1233
1234 // Reload prefab data
1235 if (IsVirtual())
1236 {
1237 return Init(TypeName, StringAnsiView(tmpBuffer.GetString(), (int32)tmpBuffer.GetSize()));
1238 }
1239#if 1 // Set to 0 to use memory-only reload that does not modifies the source file - useful for testing and debugging prefabs apply
1240#if COMPILE_WITH_ASSETS_IMPORTER
1241 Locker.Unlock();
1242
1243 // Save to file
1244 if (CreateJson::Create(GetPath(), tmpBuffer, Prefab::TypeName))
1245 {
1246 Locker.Lock();
1247 LOG(Warning, "Failed to serialize prefab data to the asset.");
1248 return true;
1249 }
1250
1251 // Ensure to be loaded
1252 if (WaitForLoaded())
1253 {
1254 Locker.Lock();
1255 LOG(Warning, "Waiting for prefab asset reload failed.");
1256 return true;
1257 }
1258
1259 Locker.Lock();
1260#else
1261#error "Cannot support prefabs creating without assets importing enabled."
1262#endif
1263#else
1264 {
1265 // Create object data
1266 rapidjson_flax::StringBuffer buffer;
1267 PrettyJsonWriter writerObj(buffer);
1268 JsonWriter& writer = writerObj;
1269 writer.StartObject();
1270 {
1271 // Json resource header
1272 writer.JKEY("ID");
1273 writer.Guid(GetID());
1274 writer.JKEY("TypeName");
1275 writer.String(TypeName);
1276 writer.JKEY("EngineBuild");
1277 writer.Int(FLAXENGINE_VERSION_BUILD);
1278

Callers

nothing calls this directly

Calls 15

IsVirtualFunction · 0.85
GetPathFunction · 0.85
GetIDFunction · 0.85
GetGuidFunction · 0.85
UnlockMethod · 0.80
LockMethod · 0.80
GuidMethod · 0.80
DeleteObjectMethod · 0.80
FindMemberMethod · 0.80
MemberEndMethod · 0.80
InitFunction · 0.50
StringAnsiViewClass · 0.50

Tested by

no test coverage detected