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

Method Resave

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

Source from the content-addressed store, hash-verified

780}
781
782bool Prefab::Resave()
783{
784 if (OnCheckSave())
785 return true;
786 PROFILE_CPU_NAMED("Prefab.Resave");
787 ScopeLock lock(Locker);
788
789 Dictionary<Guid, Guid> objectIds;
790 objectIds.EnsureCapacity(ObjectsIds.Count());
791 for (int32 i = 0; i < ObjectsIds.Count(); i++)
792 {
793 Guid id = ObjectsIds[i];
794 objectIds.Add(id, id);
795 }
796 PrefabManager::SpawnOptions options;
797 options.WithLink = false;
798 options.IDs = &objectIds;
799 auto instance = PrefabManager::SpawnPrefab(this, options);
800 if (instance == nullptr)
801 return true;
802
803 // Serialize to json data
804 CollectionPoolCache<ActorsCache::SceneObjectsListType>::ScopeCache sceneObjects = ActorsCache::SceneObjectsListCache.Get();
805 SceneQuery::GetAllSerializableSceneObjects(instance, *sceneObjects.Value);
806 rapidjson_flax::StringBuffer dataBuffer;
807 {
808 PrettyJsonWriter writerObj(dataBuffer);
809 PrefabInstanceData::SerializeObjects(*sceneObjects.Value, writerObj);
810 }
811
812 // Remove temporary objects
813 instance->DeleteObject();
814 instance = nullptr;
815
816 // Save to file
817 if (CreateJson::Create(GetPath(), dataBuffer, TypeName))
818 {
819 LOG(Warning, "Failed to serialize prefab data to the asset.");
820 return true;
821 }
822
823 return false;
824}
825
826bool Prefab::ApplyAllInternal(Actor* targetActor, bool linkTargetActorObjectToPrefab, PrefabInstancesData& prefabInstancesData)
827{

Callers 1

OnEndMethod · 0.80

Calls 7

GetPathFunction · 0.85
DeleteObjectMethod · 0.80
CreateFunction · 0.50
EnsureCapacityMethod · 0.45
CountMethod · 0.45
AddMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected