当 PlayableDirector 组件开始播放时触发的事件。
向此事件添加事件处理程序,以在 PlayableDirector 开始播放时接收通知。处理程序还会接收正在播放的 PlayableDirector。
当使用 PlayableBehaviour 时,此事件将在 PlayableBehaviour.OnPlayableCreate 之后,PlayableBehaviour.OnGraphStart 和 PlayableBehaviour.OnBehaviourPlay 之前触发。
如果 PlayableDirector 使用 PlayableDirector.playOnAwake 自动播放,则不会触发此事件。
using UnityEngine; using UnityEngine.Playables;
public class PlayableDirectorCallbackExample : MonoBehaviour { public PlayableDirector director;
void OnEnable() { director.played += OnPlayableDirectorPlayed; }
void OnPlayableDirectorPlayed(PlayableDirector aDirector) { if (director == aDirector) Debug.Log("PlayableDirector named " + aDirector.name + " is now playing."); }
void OnDisable() { director.played -= OnPlayableDirectorPlayed; } }