CinemachineTrack.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if !UNITY_2019_1_OR_NEWER
  2. #define CINEMACHINE_TIMELINE
  3. #endif
  4. #if CINEMACHINE_TIMELINE
  5. using System;
  6. using UnityEngine;
  7. using UnityEngine.Playables;
  8. using UnityEngine.Timeline;
  9. using Cinemachine;
  10. //namespace Cinemachine.Timeline
  11. //{
  12. [Serializable]
  13. [TrackClipType(typeof(CinemachineShot))]
  14. #if !UNITY_2018_2_OR_NEWER
  15. [TrackMediaType(TimelineAsset.MediaType.Script)]
  16. #endif
  17. #if UNITY_2018_3_OR_NEWER
  18. [TrackBindingType(typeof(CinemachineBrain), TrackBindingFlags.None)]
  19. #else
  20. [TrackBindingType(typeof(CinemachineBrain))]
  21. #endif
  22. [TrackColor(0.53f, 0.0f, 0.08f)]
  23. public class CinemachineTrack : TrackAsset
  24. {
  25. public override Playable CreateTrackMixer(
  26. PlayableGraph graph, GameObject go, int inputCount)
  27. {
  28. #if !UNITY_2019_2_OR_NEWER
  29. // Hack to set the display name of the clip to match the vcam
  30. foreach (var c in GetClips())
  31. {
  32. CinemachineShot shot = (CinemachineShot)c.asset;
  33. CinemachineVirtualCameraBase vcam = shot.VirtualCamera.Resolve(graph.GetResolver());
  34. if (vcam != null)
  35. c.displayName = vcam.Name;
  36. }
  37. #endif
  38. var mixer = ScriptPlayable<CinemachineMixer>.Create(graph);
  39. mixer.SetInputCount(inputCount);
  40. return mixer;
  41. }
  42. }
  43. //}
  44. #endif