35 lines
590 B
C#
35 lines
590 B
C#
using NodeCanvas.Framework;
|
|
using UnityEngine.Playables;
|
|
|
|
namespace BITKit.NodeCanvas.Timeline
|
|
{
|
|
public class PlayTimeline : ActionTask<PlayableDirector>
|
|
{
|
|
public BBParameter<bool> waitUntilFinish;
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
if(waitUntilFinish.value)
|
|
{
|
|
agent.stopped += OnPlayEnd;
|
|
}
|
|
agent.time = 0;
|
|
agent.Play();
|
|
}
|
|
|
|
protected override void OnStop()
|
|
{
|
|
base.OnStop();
|
|
if (waitUntilFinish.value)
|
|
{
|
|
agent.stopped -= OnPlayEnd;
|
|
}
|
|
}
|
|
private void OnPlayEnd(PlayableDirector obj)
|
|
{
|
|
EndAction();
|
|
}
|
|
}
|
|
|
|
} |