using System;
using System.Collections.Generic;
using UnityEngine.Playables;
using UnityEngine.SceneManagement;
using UnityEngine.Timeline;
namespace UnityEngine.Sequences.Timeline
{
///
/// A track you can use to control the active state of a Scene.
///
[Serializable]
[TrackClipType(typeof(SceneActivationPlayableAsset))]
[TrackColor(0.55f, 0.5f, 0.14f)]
public class SceneActivationTrack : TrackAsset
{
///
/// A reference to the Scene to control through this track.
///
public SceneReference scene;
List m_Buffer = new List();
/// [doc-replica] com.unity.timeline
///
/// Creates a mixer to blend playables generated by clips on the track.
///
/// The graph to inject playables into.
/// The GameObject that requested the graph.
/// The number of playables from clips that will be inputs to the returned mixer.
/// A handle to the that represents the mixer.
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
{
ScriptPlayable mixer = ScriptPlayable.Create(graph, inputCount);
mixer.GetBehaviour().SetData(scene);
return mixer;
}
/// [doc-replica] com.unity.timeline
///
/// The Timeline Editor calls this method to gather properties that require a preview.
///
/// The PlayableDirector that invokes the preview.
/// The PropertyCollector used to gather previewable properties.
public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
{
Scene loadedScene = SceneActivationManager.GetScene(scene.path);
if (!loadedScene.isLoaded)
return;
m_Buffer.Clear();
// TODO: this should be defined by the SceneActivationBehaviour.
loadedScene.GetRootGameObjects(m_Buffer);
foreach (GameObject root in m_Buffer)
driver.AddFromName(root, "m_IsActive");
}
}
}