hiding button to add non-uniform scale when there already is a NUS component on the entity
This commit is contained in:
+42
-11
@@ -1217,10 +1217,47 @@ namespace AzToolsFramework
|
|||||||
destinationComponent->SetWorldTM(const_cast<TransformComponent*>(sourceComponent)->GetWorldTM());
|
destinationComponent->SetWorldTM(const_cast<TransformComponent*>(sourceComponent)->GetWorldTM());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AZ::Component* TransformComponent::FindPresentOrPendingComponent(AZ::Uuid componentUuid)
|
||||||
|
{
|
||||||
|
// first check if the component is present and valid
|
||||||
|
AZ::Component* foundComponent = GetEntity()->FindComponent(componentUuid);
|
||||||
|
if (foundComponent)
|
||||||
|
{
|
||||||
|
return foundComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// then check to see if there's a component pending because it's in an invalid state
|
||||||
|
AZStd::vector<AZ::Component*> pendingComponents;
|
||||||
|
AzToolsFramework::EditorPendingCompositionRequestBus::Event(GetEntityId(),
|
||||||
|
&AzToolsFramework::EditorPendingCompositionRequests::GetPendingComponents, pendingComponents);
|
||||||
|
|
||||||
|
for (const auto pendingComponent : pendingComponents)
|
||||||
|
{
|
||||||
|
if (pendingComponent->RTTI_IsTypeOf(componentUuid))
|
||||||
|
{
|
||||||
|
return pendingComponent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
AZ::Crc32 TransformComponent::AddNonUniformScaleButtonVisibility()
|
||||||
|
{
|
||||||
|
// if there is a non-uniform scale component already, hide altogether
|
||||||
|
if (FindPresentOrPendingComponent(EditorNonUniformScaleComponent::TYPEINFO_Uuid()))
|
||||||
|
{
|
||||||
|
return AZ::Edit::PropertyVisibility::Hide;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, just show children
|
||||||
|
return AZ::Edit::PropertyVisibility::ShowChildrenOnly;
|
||||||
|
}
|
||||||
|
|
||||||
AZ::Crc32 TransformComponent::OnAddNonUniformScaleButtonPressed()
|
AZ::Crc32 TransformComponent::OnAddNonUniformScaleButtonPressed()
|
||||||
{
|
{
|
||||||
// if there is already a non-uniform scale component, do nothing
|
// if there is already a non-uniform scale component, do nothing
|
||||||
if (GetEntity()->FindComponent<EditorNonUniformScaleComponent>())
|
if (FindPresentOrPendingComponent(EditorNonUniformScaleComponent::TYPEINFO_Uuid()))
|
||||||
{
|
{
|
||||||
return AZ::Edit::PropertyRefreshLevels::None;
|
return AZ::Edit::PropertyRefreshLevels::None;
|
||||||
}
|
}
|
||||||
@@ -1232,17 +1269,11 @@ namespace AzToolsFramework
|
|||||||
AzToolsFramework::EntityCompositionRequestBus::BroadcastResult(outcome,
|
AzToolsFramework::EntityCompositionRequestBus::BroadcastResult(outcome,
|
||||||
&AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, entityList, componentsToAdd);
|
&AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, entityList, componentsToAdd);
|
||||||
|
|
||||||
AZStd::vector<AZ::Component*> pendingComponents;
|
|
||||||
AzToolsFramework::EditorPendingCompositionRequestBus::Event(GetEntityId(),
|
|
||||||
&AzToolsFramework::EditorPendingCompositionRequests::GetPendingComponents, pendingComponents);
|
|
||||||
|
|
||||||
AZ::ComponentId nonUniformScaleComponentId = AZ::InvalidComponentId;
|
AZ::ComponentId nonUniformScaleComponentId = AZ::InvalidComponentId;
|
||||||
for (const auto pendingComponent : pendingComponents)
|
auto nonUniformScaleComponent = FindPresentOrPendingComponent(EditorNonUniformScaleComponent::RTTI_Type());
|
||||||
|
if (nonUniformScaleComponent)
|
||||||
{
|
{
|
||||||
if (pendingComponent->RTTI_IsTypeOf(AzToolsFramework::Components::EditorNonUniformScaleComponent::RTTI_Type()))
|
nonUniformScaleComponentId = nonUniformScaleComponent->GetId();
|
||||||
{
|
|
||||||
nonUniformScaleComponentId = pendingComponent->GetId();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!outcome.IsSuccess() || nonUniformScaleComponentId == AZ::InvalidComponentId)
|
if (!outcome.IsSuccess() || nonUniformScaleComponentId == AZ::InvalidComponentId)
|
||||||
@@ -1300,7 +1331,7 @@ namespace AzToolsFramework
|
|||||||
Attribute(AZ::Edit::Attributes::AutoExpand, true)->
|
Attribute(AZ::Edit::Attributes::AutoExpand, true)->
|
||||||
DataElement(AZ::Edit::UIHandlers::Default, &TransformComponent::m_addNonUniformScaleButton, "", "")->
|
DataElement(AZ::Edit::UIHandlers::Default, &TransformComponent::m_addNonUniformScaleButton, "", "")->
|
||||||
Attribute(AZ::Edit::Attributes::AutoExpand, true)->
|
Attribute(AZ::Edit::Attributes::AutoExpand, true)->
|
||||||
Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)->
|
Attribute(AZ::Edit::Attributes::Visibility, &TransformComponent::AddNonUniformScaleButtonVisibility)->
|
||||||
Attribute(AZ::Edit::Attributes::ChangeNotify, &TransformComponent::OnAddNonUniformScaleButtonPressed)->
|
Attribute(AZ::Edit::Attributes::ChangeNotify, &TransformComponent::OnAddNonUniformScaleButtonPressed)->
|
||||||
DataElement(AZ::Edit::UIHandlers::ComboBox, &TransformComponent::m_parentActivationTransformMode,
|
DataElement(AZ::Edit::UIHandlers::ComboBox, &TransformComponent::m_parentActivationTransformMode,
|
||||||
"Parent activation", "Configures relative transform behavior when parent activates.")->
|
"Parent activation", "Configures relative transform behavior when parent activates.")->
|
||||||
|
|||||||
+2
-2
@@ -37,8 +37,6 @@ namespace AzToolsFramework
|
|||||||
public:
|
public:
|
||||||
AZ_TYPE_INFO(AddNonUniformScaleButton, "{92ECB8B6-DD25-4FC0-A5EE-4CEBAF51A780}")
|
AZ_TYPE_INFO(AddNonUniformScaleButton, "{92ECB8B6-DD25-4FC0-A5EE-4CEBAF51A780}")
|
||||||
static void Reflect(AZ::ReflectContext* context);
|
static void Reflect(AZ::ReflectContext* context);
|
||||||
private:
|
|
||||||
void OnAddNonUniformScaleButtonPressed() {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Manages transform data as separate vector fields for editing purposes.
|
/// Manages transform data as separate vector fields for editing purposes.
|
||||||
@@ -238,6 +236,8 @@ namespace AzToolsFramework
|
|||||||
|
|
||||||
void CheckApplyCachedWorldTransform(const AZ::Transform& parentWorld);
|
void CheckApplyCachedWorldTransform(const AZ::Transform& parentWorld);
|
||||||
|
|
||||||
|
AZ::Component* FindPresentOrPendingComponent(AZ::Uuid componentUuid);
|
||||||
|
AZ::Crc32 AddNonUniformScaleButtonVisibility();
|
||||||
AZ::Crc32 OnAddNonUniformScaleButtonPressed();
|
AZ::Crc32 OnAddNonUniformScaleButtonPressed();
|
||||||
|
|
||||||
// Drives transform behavior when parent activates. See AZ::TransformConfig::ParentActivationTransformMode for details.
|
// Drives transform behavior when parent activates. See AZ::TransformConfig::ParentActivationTransformMode for details.
|
||||||
|
|||||||
Reference in New Issue
Block a user