I bake the GameObject into Entiy and Instantiate it, then i got a Entity that looks diffent then the GameObject
The GameObject structure looks like this, parent got a non uniform scale (2,1,1), and the child got a rotation(0,0,30)
the GameObject
the Instantiate Entity
I think non uniform scale is the problem, if a parent transform has non uniform scale, then child transform will looks weird, if the chilid has arbitrary rotation at the same time.
why this happen? is that a bug or i mess something up? i need to use non uniform scale Entity at my project, plaease help.
This is the spawn script
public class TestSpawn : MonoBehaviour
{
public GameObject prefab;
public class Baker : Baker<TestSpawn>
{
public override void Bake(TestSpawn authoring)
{
Entity entity = GetEntity(TransformUsageFlags.NonUniformScale);
AddComponent(entity, new TestSpawnData
{
Prefab = GetEntity(authoring.prefab, TransformUsageFlags.NonUniformScale),
});
}
}
}
public struct TestSpawnData : IComponentData
{
public Entity Prefab;
}
public partial class TestSpawnSystem : SystemBase
{
protected override void OnCreate()
{
RequireForUpdate<TestSpawnData>();
}
protected override void OnUpdate()
{
this.Enabled = false;
TestSpawnData spawn = SystemAPI.GetSingleton<TestSpawnData>();
EntityCommandBuffer entityCommandBuffer = new EntityCommandBuffer(WorldUpdateAllocator);
Entity spawnedEntity = entityCommandBuffer.Instantiate(spawn.Prefab);
entityCommandBuffer.SetComponent(spawnedEntity, new LocalTransform
{
Position = new Unity.Mathematics.float3(0, 0, 0),
Rotation = quaternion.identity,
Scale = 1
});
entityCommandBuffer.SetComponent(spawnedEntity, new PostTransformMatrix
{
Value = float4x4.Scale(2, 1, 1)
});
entityCommandBuffer.Playback(EntityManager);
}
}