[LYN-7064] Hot Loading of Procedural Prefabs (#4923)

* Prefab hotloading - load and maintain asset references

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Working hotloading

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Clean up code, add comments

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add missing includes

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add event for template removal.

Clear ProceduralPrefabSystemComponent lookup when templates are removed.

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add unit test.

Fix missing include, make sure source name is set

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix missing include

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix missing include

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Update comments to make ebus event behavior more clear

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix missing include

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix missing includes

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix missing include

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix temp directory usage which doesn't work on linux

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix temp directory usage which doesn't work on linux

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Use AZ::IO::Path for comparison.  Print paths on failure

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Fix unit test - register asset with catalog so it can be looked up later

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
This commit is contained in:
amzn-mike
2021-12-13 14:44:41 -06:00
committed by GitHub
parent 45abb9f88e
commit 71bb200e0a
14 changed files with 595 additions and 15 deletions
@@ -160,7 +160,7 @@ namespace AzToolsFramework
newInstance->SetTemplateId(newTemplateId);
}
}
void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId, InstanceOptionalConstReference instanceToExclude)
{
auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId);
@@ -442,7 +442,7 @@ namespace AzToolsFramework
}
m_templateFilePathToIdMap.emplace(AZStd::make_pair(filePath, newTemplateId));
return newTemplateId;
}
@@ -469,7 +469,7 @@ namespace AzToolsFramework
{
return;
}
m_templateFilePathToIdMap.erase(templateToChange.GetFilePath());
if (!m_templateFilePathToIdMap.try_emplace(filePath, templateId).second)
{
@@ -500,7 +500,7 @@ namespace AzToolsFramework
return;
}
//Remove all Links owned by the Template from TemplateToLinkIdsMap.
Template& templateToDelete = findTemplateResult->get();
const Template::Links& linkIdsToDelete = templateToDelete.GetLinks();
@@ -546,7 +546,7 @@ namespace AzToolsFramework
templateId, templateToDelete.GetFilePath().c_str());
m_templateInstanceMapper.UnregisterTemplate(templateId);
result = m_templateIdMap.erase(templateId) != 0;
AZ_Assert(result,
"Prefab - PrefabSystemComponent::RemoveTemplate - "
@@ -554,7 +554,10 @@ namespace AzToolsFramework
"from Template Id Map.",
templateId, templateToDelete.GetFilePath().c_str());
return;
if (!m_removingAllTemplates)
{
PrefabPublicNotificationBus::Broadcast(&PrefabPublicNotificationBus::Events::OnTemplateRemoved, templateId);
}
}
void PrefabSystemComponent::RemoveAllTemplates()
@@ -568,10 +571,15 @@ namespace AzToolsFramework
templateIds.emplace_back(id);
}
m_removingAllTemplates = true;
for (auto id : templateIds)
{
RemoveTemplate(id);
}
m_removingAllTemplates = false;
PrefabPublicNotificationBus::Broadcast(&PrefabPublicNotificationBus::Events::OnAllTemplatesRemoved);
}
LinkId PrefabSystemComponent::AddLink(
@@ -859,7 +867,7 @@ namespace AzToolsFramework
void PrefabSystemComponent::SaveAllDirtyTemplates(TemplateId rootTemplateId)
{
AZStd::set<AZ::IO::PathView> dirtyTemplatePaths = GetDirtyTemplatePaths(rootTemplateId);
AZStd::set<AZ::IO::PathView> dirtyTemplatePaths = GetDirtyTemplatePaths(rootTemplateId);
for (AZ::IO::PathView dirtyTemplatePath : dirtyTemplatePaths)
{