using System; using UnityEngine; using UnityEngine.Playables; using UnityEngine.Timeline; using UnityEngine.Video; namespace uc.Timeline { [Serializable] [TrackClipType(typeof(MoviePlayerClip))] //[TrackMediaType(TimelineAsset.MediaType.Script)] [TrackBindingType(typeof(MoviePlayerBase))] [TrackColor(0.53f, 0.0f, 0.08f)] //[SupportsChildTracks(typeof(MoviePlayerTrack), 1)] public class MoviePlayerTrack : TrackAsset { public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) { //Debug.Log("MoviePlayerTrack.CreateTrackMixer"); // Hack to set the display name of the clip to match the vcam foreach (var c in GetClips()) { MoviePlayerClip shot = (MoviePlayerClip)c.asset; //CinemachineVirtualCameraBase vcam = shot.VirtualCamera.Resolve(graph.GetResolver()); if(shot.movie != null) c.displayName = shot.movie.VideoAsset.fullPath; } var mixer = ScriptPlayable.Create(graph); mixer.SetInputCount(inputCount); return mixer; } #if UNITY_2018_1_OR_NEWER internal protected new Playable CreatePlayable(PlayableGraph graph, GameObject go, TimelineClip clip) #else protected override Playable CreatePlayable(PlayableGraph graph, GameObject go, TimelineClip clip) #endif { //Debug.Log("MoviePlayerTrack.CreatePlayable"); PlayableDirector d = go.GetComponent(); if (d != null) { MoviePlayerBase movie = d.GetGenericBinding(this) as MoviePlayerBase; if (movie != null && clip.asset is MoviePlayerClip) (clip.asset as MoviePlayerClip).movie = movie; } return base.CreatePlayable(graph, go, clip); } } }