2020-12-06 02:36:15 +01:00
|
|
|
|
using Unity.Entities;
|
|
|
|
|
using Unity.Transforms;
|
|
|
|
|
using Unity.Collections;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace TAO.VertexAnimation
|
|
|
|
|
{
|
|
|
|
|
[DisallowMultipleComponent]
|
|
|
|
|
public class VA_AnimatorComponentAuthoring : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[GenerateAuthoringComponent]
|
|
|
|
|
public struct VA_AnimatorComponent : IComponentData
|
|
|
|
|
{
|
|
|
|
|
public int animationIndex;
|
|
|
|
|
public int animationIndexSchedule;
|
|
|
|
|
public float animationTime;
|
2020-12-08 17:36:20 +01:00
|
|
|
|
public BlobAssetReference<VA_AnimationDataBlobAsset> animationsRef;
|
2020-12-06 02:36:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-08 17:36:20 +01:00
|
|
|
|
[UpdateAfter(typeof(VA_AnimationDataBlobAssetConversionSystem))]
|
2020-12-06 02:36:15 +01:00
|
|
|
|
public class VA_AnimatorConversionSystem : GameObjectConversionSystem
|
|
|
|
|
{
|
|
|
|
|
protected override void OnUpdate()
|
|
|
|
|
{
|
2020-12-08 17:36:20 +01:00
|
|
|
|
BlobAssetStore.TryGet(new Unity.Entities.Hash128("AnimationLib"), out BlobAssetReference<VA_AnimationDataBlobAsset> assetReference);
|
|
|
|
|
|
2020-12-06 02:36:15 +01:00
|
|
|
|
Entities.ForEach((VA_AnimatorComponentAuthoring animator) =>
|
|
|
|
|
{
|
|
|
|
|
Entity entity = GetPrimaryEntity(animator);
|
2020-12-08 17:36:20 +01:00
|
|
|
|
|
2020-12-06 02:36:15 +01:00
|
|
|
|
// Add animator to 'parent'.
|
|
|
|
|
VA_AnimatorComponent animatorComponent = new VA_AnimatorComponent
|
|
|
|
|
{
|
|
|
|
|
animationIndex = 0,
|
|
|
|
|
animationIndexSchedule = -1,
|
|
|
|
|
animationTime = 0,
|
2020-12-08 17:36:20 +01:00
|
|
|
|
animationsRef = assetReference
|
|
|
|
|
};
|
2020-12-06 02:36:15 +01:00
|
|
|
|
DstEntityManager.AddComponentData(entity, animatorComponent);
|
|
|
|
|
|
|
|
|
|
// Add the Material data to the children.
|
|
|
|
|
var children = animator.GetComponentsInChildren<MeshRenderer>();
|
|
|
|
|
for (int i = 0; i < children.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
Entity ent = GetPrimaryEntity(children[i]);
|
|
|
|
|
|
|
|
|
|
VA_AnimationIndexComponent animationIndex = new VA_AnimationIndexComponent { Value = 0 };
|
|
|
|
|
DstEntityManager.AddComponentData(ent, animationIndex);
|
|
|
|
|
VA_AnimationTimeComponent animationTime = new VA_AnimationTimeComponent { Value = 0 };
|
|
|
|
|
DstEntityManager.AddComponentData(ent, animationTime);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|