Use scripting to control playback
Scripting for Doodle Studio 95! is inspired by Flash’s playback methods.
Methods
DoodleAnimator animator = gameObject.GetComponent<DoodleAnimator>();
animator.Play(); // Plays from start to finish, uses the animator's playback settings
animator.Pause(); // Stops playing and keeps the animation visible
animator.Stop(); // Stops playing and hides the animation
animator.GotoAndPlay(3); // Starts playback at frame 3
animator.GotoAndPause(3); // Moves the playhead to frame 3 and pauses
// Call inside a coroutine to starts playback at 0 and pauses at the last frame
// and wait until the animation is finished
yield return animator.PlayAndPauseAt(0, -1));
animator.ChangeAnimation(newAnimationFile); // Changes the animation
ChainAnimations.cs
Use this component to play a sequence of animations in a row.
[RequireComponent(typeof(DoodleAnimator))]
public class ChainAnimations : MonoBehaviour {
public DoodleAnimationFile[] m_Animations;
[Header("Settings")]
public bool m_PlayOnStart = true;
public bool m_Loop = true;
void Start () {
if (m_PlayOnStart)
Play();
}
IEnumerator PlaySequence() {
DoodleAnimator animator = GetComponent<DoodleAnimator>();
int i = 0;
while(i < m_Animations.Length) {
// Set the new animation
animator.ChangeAnimation(m_Animations[i]);
// Play the animation and wait until it's finished
yield return animator.PlayAndPauseAt();
// Advanced to the next animation
i++;
// Loop if we've reached the end
if (i >= m_Animations.Length && m_Loop)
i = 0;
}
animator.Stop();
}
public void Play() {
StopAllCoroutines();
StartCoroutine(PlaySequence());
}
}