@@ -202,34 +202,30 @@ namespace ROS2
202
202
}
203
203
204
204
AZ::Entity* entity = AzToolsFramework::GetEntityById (entityId);
205
- auto editorMeshComponent = entity->CreateComponent (AZ::Render::EditorMeshComponentTypeId);
206
205
207
- // Prepare scale
208
206
bool isUniformScale = AZ::IsClose (scale.GetMaxElement (), scale.GetMinElement (), AZ::Constants::FloatEpsilon);
209
- if (! isUniformScale)
207
+ if (isUniformScale)
210
208
{
211
- entity->CreateComponent <AzToolsFramework::Components::EditorNonUniformScaleComponent>();
209
+ auto * transformComponent = entity->FindComponent (AZ::EditorTransformComponentTypeId);
210
+ AZ_Assert (transformComponent, " Entity doesn't have a transform component." );
211
+ auto * transformInterface = azrtti_cast<AZ::TransformInterface*>(transformComponent);
212
+ AZ_Assert (transformInterface, " Found component has no transformInterface" );
213
+ transformInterface->SetLocalUniformScale (scale.GetX ());
214
+ }
215
+ else
216
+ {
217
+ auto component = entity->CreateComponent <AzToolsFramework::Components::EditorNonUniformScaleComponent>();
218
+ AZ_Assert (component, " EditorNonUniformScaleComponent was not created" );
219
+ component->SetScale (scale);
212
220
}
213
221
222
+ auto editorMeshComponent = entity->CreateComponent (AZ::Render::EditorMeshComponentTypeId);
214
223
if (editorMeshComponent)
215
224
{
216
225
auto editorBaseComponent = azrtti_cast<AzToolsFramework::Components::EditorComponentBase*>(editorMeshComponent);
217
226
AZ_Assert (editorBaseComponent, " EditorMeshComponent didn't derive from EditorComponentBase." );
218
227
editorBaseComponent->SetPrimaryAsset (assetId);
219
228
}
220
-
221
- entity->Activate ();
222
-
223
- // Set scale, uniform or non-uniform
224
- if (isUniformScale)
225
- {
226
- AZ::TransformBus::Event (entityId, &AZ::TransformBus::Events::SetLocalUniformScale, scale.GetX ());
227
- }
228
- else
229
- {
230
- AZ::NonUniformScaleRequestBus::Event (entityId, &AZ::NonUniformScaleRequests::SetScale, scale);
231
- }
232
- entity->Deactivate ();
233
229
}
234
230
235
231
static void OverrideScriptMaterial (const sdf::Material* material, AZ::Render::MaterialAssignmentMap& overrides)
0 commit comments