| 780 | } |
| 781 | |
| 782 | bool 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 | |
| 826 | bool Prefab::ApplyAllInternal(Actor* targetActor, bool linkTargetActorObjectToPrefab, PrefabInstancesData& prefabInstancesData) |
| 827 | { |
no test coverage detected