Created
January 21, 2020 17:02
-
-
Save wiverson/5a7175fab15c96b4e9e192eb3b2acfb7 to your computer and use it in GitHub Desktop.
Reset a Unity3d PlayableDirector / Timeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
using UnityEngine.Playables; | |
public class ResetTimeline : MonoBehaviour | |
{ | |
public PlayableDirector playableDirector; | |
private void Start() | |
{ | |
if (!playableDirector) | |
throw new ArgumentException("Missing Playable Director"); | |
} | |
public void ResetPlayableDirector() | |
{ | |
playableDirector.Stop(); | |
playableDirector.time = 0; | |
playableDirector.Evaluate(); | |
playableDirector.Play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment