ClipCaps.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using UnityEngine.Playables;
  3. namespace UnityEngine.Timeline
  4. {
  5. /// <summary>
  6. /// Describes the timeline features supported by a clip
  7. /// </summary>
  8. [Flags]
  9. public enum ClipCaps
  10. {
  11. /// <summary>
  12. /// No features are supported.
  13. /// </summary>
  14. None = 0 ,
  15. /// <summary>
  16. /// The clip supports loops.
  17. /// </summary>
  18. Looping = 1 << 0,
  19. /// <summary>
  20. /// The clip supports clip extrapolation.
  21. /// </summary>
  22. Extrapolation = 1 << 1,
  23. /// <summary>
  24. /// The clip supports initial local times greater than zero.
  25. /// </summary>
  26. ClipIn = 1 << 2,
  27. /// <summary>
  28. /// The clip supports time scaling.
  29. /// </summary>
  30. SpeedMultiplier = 1 << 3,
  31. /// <summary>
  32. /// The clip supports blending between clips.
  33. /// </summary>
  34. Blending = 1 << 4,
  35. /// <summary>
  36. /// All features are supported.
  37. /// </summary>
  38. All = ~None
  39. }
  40. static class TimelineClipCapsExtensions
  41. {
  42. public static bool SupportsLooping(this TimelineClip clip)
  43. {
  44. return clip != null && (clip.clipCaps & ClipCaps.Looping) != ClipCaps.None;
  45. }
  46. public static bool SupportsExtrapolation(this TimelineClip clip)
  47. {
  48. return clip != null && (clip.clipCaps & ClipCaps.Extrapolation) != ClipCaps.None;
  49. }
  50. public static bool SupportsClipIn(this TimelineClip clip)
  51. {
  52. return clip != null && (clip.clipCaps & ClipCaps.ClipIn) != ClipCaps.None;
  53. }
  54. public static bool SupportsSpeedMultiplier(this TimelineClip clip)
  55. {
  56. return clip != null && (clip.clipCaps & ClipCaps.SpeedMultiplier) != ClipCaps.None;
  57. }
  58. public static bool SupportsBlending(this TimelineClip clip)
  59. {
  60. return clip != null && (clip.clipCaps & ClipCaps.Blending) != ClipCaps.None;
  61. }
  62. public static bool HasAll(this ClipCaps caps, ClipCaps flags)
  63. {
  64. return (caps & flags) == flags;
  65. }
  66. public static bool HasAny(this ClipCaps caps, ClipCaps flags)
  67. {
  68. return (caps & flags) != 0;
  69. }
  70. }
  71. }