...
using UnityEngine.Playables;//Timeline
...
/// <summary>
/// Playable Director组件的物件,Inspector视图下Playable Director组件的Wrap Mode为Hold
/// </summary>
public PlayableDirector Director;//含有PlayableDirector组件的变量
/// <summary>
/// 暂停
/// </summary>
public void pause()
{
if (Director != null)
{
//Director.Pause();//动画的实体的动画的位移会重置
Director.playableGraph.GetRootPlayable(0).SetSpeed(0);
//Director.Stop();//Director.Stop();也可以暂停,但是不能从暂停的状态恢复播放
}
}//
/// <summary>
/// 恢复播放
/// </summary>
public void resume()
{
if (Director != null)
{
//Director.Resume();//
Director.playableGraph.GetRootPlayable(0).SetSpeed(1);
}
}
...
暂停播放 与 恢复播放
Director.Pause();和Director.Resume();
Direc