GpuEcsAnimatedMeshBehaviour.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Unity.Entities;
  2. using Unity.Mathematics;
  3. using UnityEngine;
  4. namespace GPUECSAnimationBaker.Engine.AnimatorSystem
  5. {
  6. public class GpuEcsAnimatedMeshBehaviour : MonoBehaviour
  7. {
  8. public GpuEcsAnimatorBehaviour animator;
  9. public TransformUsageFlags transformUsageFlags = TransformUsageFlags.Renderable;
  10. }
  11. public class GpuEcsAnimatedMeshBaker : Baker<GpuEcsAnimatedMeshBehaviour>
  12. {
  13. public override void Bake(GpuEcsAnimatedMeshBehaviour authoring)
  14. {
  15. Entity entity = GetEntity(authoring.transformUsageFlags);
  16. AddComponent(entity, new GpuEcsAnimatedMeshComponent()
  17. {
  18. animatorEntity = GetEntity(authoring.animator.gameObject,
  19. authoring.animator.transformUsageFlags)
  20. });
  21. AddComponent(entity, new GpuEcsMaterialAnimationState()
  22. {
  23. Value = new float4x4(
  24. 1f, 0, 0, 0,
  25. 0, 0, 0, 0,
  26. 0, 0, 0, 0,
  27. 0, 0, 0, 0)
  28. });
  29. AddComponent(entity, new GpuEcsMaterialEnableAnimation()
  30. {
  31. Value = 1
  32. });
  33. }
  34. }
  35. }