1
This commit is contained in:
35
Src/UnityPluginsSupport/NodeCanvas/Timeline/PlayTimeline.cs
Normal file
35
Src/UnityPluginsSupport/NodeCanvas/Timeline/PlayTimeline.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user