Prefab Serialization | Remove "Source" parameter from prefab source file (#1387)

* When loading a template to memory, store the current Source (potentially overriding what was stored to disk)

* Before storing the prefab disk, remove the Source parameter from the Dom (as it's no longer necessary to save it).
This commit is contained in:
Danilo Aimini
2021-06-18 12:37:37 -07:00
committed by GitHub
parent 85af8475a5
commit acd23698ea
2 changed files with 8 additions and 0 deletions
@@ -151,6 +151,10 @@ namespace AzToolsFramework
return InvalidTemplateId;
}
// Add or replace the Source parameter in the dom
PrefabDomPath sourcePath = PrefabDomPath((AZStd::string("/") + PrefabDomUtils::SourceName).c_str());
sourcePath.Set(readPrefabFileResult.GetValue(), relativePath.Native().c_str());
// Create new Template with the Prefab DOM.
TemplateId newTemplateId = m_prefabSystemComponentInterface->AddTemplate(relativePath, readPrefabFileResult.TakeValue());
if (newTemplateId == InvalidTemplateId)
@@ -207,6 +207,10 @@ namespace AzToolsFramework
instanceValue->CopyFrom(linkDom, m_prefabDom.GetAllocator());
}
// Remove Source parameter from the dom. It will be added on file load, and should not be stored to disk.
PrefabDomPath sourcePath = PrefabDomPath((AZStd::string("/") + PrefabDomUtils::SourceName).c_str());
sourcePath.Erase(output);
return true;
}