This commit is contained in:
2025-08-31 20:46:27 +02:00
parent 2d06552025
commit 104259f79b
11 changed files with 310 additions and 137 deletions

View File

@@ -1,24 +1,53 @@
using UnityEngine;
using System;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
namespace RebootKit.Engine.Animations {
[Serializable]
public class AnimationClipNode : IReAnimatorNode {
[field: SerializeField] public string Name { get; private set; }
AnimationClipPlayable m_Playable;
bool m_PlayOnce;
Action m_Callback;
public AnimationClip Clip;
public void Tick(float deltaTime) {
if (m_Playable.GetPlayState() == PlayState.Paused) {
return;
}
if (m_PlayOnce) {
if (m_Playable.GetTime() >= m_Playable.GetAnimationClip().length) {
m_Playable.Pause();
m_Callback?.Invoke();
m_Callback = null;
m_PlayOnce = false;
}
}
}
public IPlayable Build(PlayableGraph graph) {
AnimationClipPlayable playable = AnimationClipPlayable.Create(graph, Clip);
return playable;
m_Playable = AnimationClipPlayable.Create(graph, Clip);
return m_Playable;
}
public bool TryFindChild(string name, out IReAnimatorNode node) {
node = null;
return false;
}
public void PlayOnceWithCallback(Action callback) {
m_Playable.SetTime(0.0);
m_Playable.Play();
m_Callback = callback;
m_PlayOnce = true;
}
}
}