MediaPlayerControlTrack.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // You need to define AVPRO_PACKAGE_TIMELINE manually to use this script
  2. // We could set up the asmdef to reference the package, but the package doesn't
  3. // existing in Unity 2017 etc, and it throws an error due to missing reference
  4. //#define AVPRO_PACKAGE_TIMELINE
  5. #if (UNITY_2018_1_OR_NEWER && AVPRO_PACKAGE_TIMELINE)
  6. using UnityEngine;
  7. using UnityEngine.Playables;
  8. using UnityEngine.Timeline;
  9. using System.Collections.Generic;
  10. //-----------------------------------------------------------------------------
  11. // Copyright 2020-2021 RenderHeads Ltd. All rights reserved.
  12. //-----------------------------------------------------------------------------
  13. namespace RenderHeads.Media.AVProVideo.Playables
  14. {
  15. [TrackClipType(typeof(MediaPlayerControlAsset))]
  16. [TrackBindingType(typeof(MediaPlayer))]
  17. public class MediaPlayerControlTrack : TrackAsset
  18. {
  19. public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
  20. {
  21. // before building, update the binding field in the clips assets;
  22. var director = go.GetComponent<PlayableDirector>();
  23. var binding = director.GetGenericBinding(this);
  24. foreach (var c in GetClips())
  25. {
  26. var myAsset = c.asset as MediaPlayerControlAsset;
  27. if (myAsset != null)
  28. {
  29. myAsset.binding = binding;
  30. }
  31. }
  32. //return base.CreateTrackMixer(graph, go, inputCount);
  33. return ScriptPlayable<MediaPlayerControlMixerBehaviour>.Create(graph, inputCount);
  34. }
  35. }
  36. }
  37. #endif