This commit is contained in:
max
2020-12-27 18:15:58 +01:00
parent 10f5dd9096
commit eb0450ce45
16 changed files with 485 additions and 344 deletions

View File

@ -1,5 +1,6 @@
using Unity.Entities;
using Unity.Mathematics;
using Unity.Collections;
using TAO.VertexAnimation;
public class SampleAnimationSystemsAuthoring : UnityEngine.MonoBehaviour
@ -7,6 +8,9 @@ public class SampleAnimationSystemsAuthoring : UnityEngine.MonoBehaviour
[UnityEngine.SerializeField]
private SampleSystem sampleSystem = SampleSystem.PlayRandomAnimation;
[UnityEngine.SerializeField]
private string animationName = "Character1Shoot";
private void Awake()
{
switch (sampleSystem)
@ -20,6 +24,7 @@ public class SampleAnimationSystemsAuthoring : UnityEngine.MonoBehaviour
case SampleSystem.PlayAnimationByName:
{
var system = World.DefaultGameObjectInjectionWorld.GetExistingSystem<PlayAnimationByNameSystem>();
system.animationName = animationName;
system.Enabled = true;
}
break;
@ -77,6 +82,8 @@ public class PlayRandomAnimationSystem : SystemBase
[UpdateBefore(typeof(VA_AnimatorSystem))]
public class PlayAnimationByNameSystem : SystemBase
{
public FixedString32 animationName;
protected override void OnCreate()
{
base.OnCreate();
@ -87,6 +94,7 @@ public class PlayAnimationByNameSystem : SystemBase
protected override void OnUpdate()
{
float deltaTime = UnityEngine.Time.deltaTime;
FixedString32 an = animationName;
Entities.ForEach((Entity entity, ref VA_AnimatorComponent ac) =>
{
@ -94,7 +102,7 @@ public class PlayAnimationByNameSystem : SystemBase
ref VA_AnimationLibraryData animationsRef = ref ac.animationLibrary.Value;
// Set the animation index on the AnimatorComponent to play this animation.
ac.animationIndex = VA_AnimationLibraryUtils.GetAnimation(ref animationsRef, "Character1Shoot");
ac.animationIndex = VA_AnimationLibraryUtils.GetAnimation(ref animationsRef, an);
// 'Play' the actual animation.
ac.animationTime += deltaTime;