AddComponent() in Baker cannot add PostTransformScale().

I tried to Add PostTransformScale in a baker. it won’t show up in the inspector window and the Entities.ForEach would not run if it’s declare “ref PostTransformScale postTransformScale”.

So It seems like not a inspector window problem, the PostTransformScale not been added at all.
Part of my baker file is like:
AddComponent(new TestComponentData()
{
testValue = 1;
});
AddComponent(new PostTransformScale(){
Value = float3x3.Scale(authoring.defaultScale)
});

The System Update is like:
Entities.ForEach((ref TestComponentData data, ref LocalTransform localTransform, ref PostTransformScale postTransformScale) => {});

Then the TestComponentData() did show up in the inspector window and the PostTransformScale did not. The system won’t run

My Unity Version is : 2022.2.10
entities: 1.0.0-pre.47

It’s not a bug. Because TransformBaking responsible for that process will remove your PostTransformScale if your authoring game object scale is uniform.

if (chunkHasPostTransformScale && requestedHasPostTransformScale)
{
    postTransformScales[i] = new PostTransformScale { Value = postTransformScale };
}
else if (requestedHasPostTransformScale)
{
    var componentTypes = new ComponentTypeSet(ComponentType.ReadWrite<PostTransformScale>(),
        ComponentType.ReadWrite<PropagateLocalToWorld>());
    Commands.AddComponent(unfilteredChunkIndex, entity, componentTypes);
    Commands.SetComponent(unfilteredChunkIndex, entity, new PostTransformScale { Value = postTransformScale });
}
else if (chunkHasPostTransformScale)
{
    Commands.RemoveComponent<PostTransformScale>(unfilteredChunkIndex, entity);
}
1 Like