Fixes up parents for entities that are moved to another Prefab.
This fixes issues with entities that are moved to another Prefab and have a parent that was also moved to the same Prefab. Entities that have their parent moved to another Prefab continue to work as is because a placeholder entity is always left behind. Entities that are moved to another Prefab but have a parent that's still in the original Prefab will currently not work correctly. This will be a addressed in a future commit. Signed-off-by: AMZN-koppersr <82230785+AMZN-koppersr@users.noreply.github.com>
This commit is contained in:
@@ -585,21 +585,24 @@ namespace AzFramework
|
||||
EBUS_EVENT_PTR(m_notificationBus, AZ::TransformNotificationBus, OnParentChanged, oldParent, parentId);
|
||||
m_parentChangedEvent.Signal(oldParent, parentId);
|
||||
|
||||
if (oldParent != parentId) // Don't send removal notification while activating.
|
||||
if (GetEntity() != nullptr)
|
||||
{
|
||||
EBUS_EVENT_ID(oldParent, AZ::TransformNotificationBus, OnChildRemoved, GetEntityId());
|
||||
auto oldParentTransform = AZ::TransformBus::FindFirstHandler(oldParent);
|
||||
if (oldParentTransform)
|
||||
if (oldParent != parentId) // Don't send removal notification while activating.
|
||||
{
|
||||
oldParentTransform->NotifyChildChangedEvent(AZ::ChildChangeType::Removed, GetEntityId());
|
||||
EBUS_EVENT_ID(oldParent, AZ::TransformNotificationBus, OnChildRemoved, GetEntityId());
|
||||
auto oldParentTransform = AZ::TransformBus::FindFirstHandler(oldParent);
|
||||
if (oldParentTransform)
|
||||
{
|
||||
oldParentTransform->NotifyChildChangedEvent(AZ::ChildChangeType::Removed, GetEntityId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EBUS_EVENT_ID(parentId, AZ::TransformNotificationBus, OnChildAdded, GetEntityId());
|
||||
auto newParentTransform = AZ::TransformBus::FindFirstHandler(parentId);
|
||||
if (newParentTransform)
|
||||
{
|
||||
newParentTransform->NotifyChildChangedEvent(AZ::ChildChangeType::Added, GetEntityId());
|
||||
EBUS_EVENT_ID(parentId, AZ::TransformNotificationBus, OnChildAdded, GetEntityId());
|
||||
auto newParentTransform = AZ::TransformBus::FindFirstHandler(parentId);
|
||||
if (newParentTransform)
|
||||
{
|
||||
newParentTransform->NotifyChildChangedEvent(AZ::ChildChangeType::Added, GetEntityId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user