using System;
using System.ComponentModel;
using UnityEngine.Playables;
using UnityEngine.Timeline;
namespace UnityEngine.Sequences.Timeline
{
///
/// The StoryboardTrack supports StoryboardPlayableAsset in order to create a Storyboard in Timeline. This allows
/// users to iterate on their cinematic timing and have a base for blocking in Unity.
///
[Serializable]
[DisplayName("Storyboard Track")]
[TrackClipType(typeof(StoryboardPlayableAsset))]
[TrackColor(237 / 255f, 126 / 255f, 2 / 255f)] // To ask UX
public class StoryboardTrack : TrackAsset
{
///
/// This is the default duration of each newly created clip on the Storyboard track. By default it is set to
/// 3 seconds, which means that every new Storyboard image added via a new clip on the track will last for 3
/// seconds.
///
/// Changing this value does not affect the duration of existing clips.
[Tooltip("Clips created in this track will be created with this default duration." +
"Changing this value with not change the length of pre-existing Clips")]
[SerializeField] public double defaultFrameDuration = 3;
///
/// The StoryboardTrack uses Canvas to display the different Storyboard frames. Use this parameter to
/// control the value.
///
[Tooltip("sorting order of the Storyboard Canvas")]
[SerializeField] public int sortOrder;
// [doc-replica] com.unity.timeline
///
/// Creates a mixer used 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 Playable node representing the mixer.
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
{
var mixer = ScriptPlayable.Create(graph, inputCount);
mixer.GetBehaviour().canvas.sortingOrder = sortOrder;
return mixer;
}
// [doc-replica] com.unity.timeline
///
/// Called when a clip is created on a track.
///
/// The timeline clip added to this track
protected override void OnCreateClip(TimelineClip clip)
{
clip.duration = defaultFrameDuration;
base.OnCreateClip(clip);
}
}
}