mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2025-06-14 15:16:10 +02:00
Samples
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user