Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Playable Director Play#

Timeline / Playable Director / Playable Director Play

Description#

Plays the Playable Asset assigned to the Playable Director

Parameters#

Name Description
Playable Director The Playable Director component that plays
Wait to Complete Waits until the Playable Director stops, or reaches the end when its Wrap Mode is Hold. A looping one never completes

Code#

using System;
using UnityEngine;
using UnityEngine.Playables;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Playable Director Play")]
    [Category("Timeline/Playable Director/Play")]
    [Description("Plays the Playable Asset assigned to the Playable Director")]

    [Image(typeof(IconDirector), ColorTheme.Type.Teal)]
    [Keywords("Timeline", "Cutscene", "Cinematic", "Sequence", "Start")]

    [Parameter("Playable Director", "The Playable Director component that plays")]
    [Parameter("Wait to Complete", "Waits until the Playable Director stops, or reaches the end when its Wrap Mode is Hold. A looping one never completes")]

    [Serializable]
    public class InstructionPlayableDirectorPlay : Instruction
    {
        [SerializeField] private GetGameObject m_PlayableDirector = new GetGameObject(
            new GenTypeGameObject_PlayableDirector()
        );

        [SerializeField] private bool m_WaitToComplete;

        [NonSerialized] private PlayableDirector m_Director;
        [NonSerialized] private Func<bool> m_CallIsComplete;

        protected override string GetTitle(GameObject source)
        {
            string method = TextUtils.ThemeAsKeyword("Play");
            return $"{this.m_PlayableDirector} {method}";
        }

        protected override async Awaitable Run(Args args)
        {
            PlayableDirector director = this.m_PlayableDirector.Get<PlayableDirector>(args);
            if (director == null) return;

            director.Play();
            if (!this.m_WaitToComplete) return;

            this.m_Director = director;
            this.m_CallIsComplete ??= this.IsComplete;

            await this.Until(this.m_CallIsComplete);
            this.m_Director = null;
        }

        private bool IsComplete()
        {
            PlayableDirector director = this.m_Director;
            if (director == null || director.state != PlayState.Playing) return true;

            if (director.extrapolationMode != DirectorWrapMode.Hold) return false;
            return director.time >= director.duration;
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.