using UnityEngine; using UnityEngine.Playables; public class IntroCinematicsPlayer : MonoBehaviour { public bool ShouldPlayIntro; public GameObject introsequence; private PlayableDirector director; void OnEnable() { // Get the director and subscribe to when it stops playing director = GetComponent(); director.stopped += OnPlayableDirectorStopped; } // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { //Play the intro and unhide the Canvas object if intro is enabled if (ShouldPlayIntro) { introsequence.SetActive(true); director.Play(); } ; //Disable the intro Canvas object if intro is disabled if (!ShouldPlayIntro) { introsequence.SetActive(false); } ; } void OnPlayableDirectorStopped(PlayableDirector aDirector) { // Disable the introsequence gameobject when intro is finished playing introsequence.SetActive(false); } // Update is called once per frame void Update() { } }