Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine.Playables;
  4. namespace UnityEngine.Timeline
  5. {
  6. static class NotificationUtilities
  7. {
  8. public static ScriptPlayable<TimeNotificationBehaviour> CreateNotificationsPlayable(PlayableGraph graph, IEnumerable<IMarker> markers, double duration, DirectorWrapMode extrapolationMode)
  9. {
  10. var notificationPlayable = ScriptPlayable<TimeNotificationBehaviour>.Null;
  11. foreach (var e in markers)
  12. {
  13. var notif = e as INotification;
  14. if (notif == null)
  15. continue;
  16. if (notificationPlayable.Equals(ScriptPlayable<TimeNotificationBehaviour>.Null))
  17. {
  18. notificationPlayable = TimeNotificationBehaviour.Create(graph,
  19. duration, extrapolationMode);
  20. }
  21. var time = (DiscreteTime)e.time;
  22. var tlDuration = (DiscreteTime)duration;
  23. if (time >= tlDuration && time <= tlDuration.OneTickAfter() && tlDuration != 0)
  24. {
  25. time = tlDuration.OneTickBefore();
  26. }
  27. var notificationOptionProvider = e as INotificationOptionProvider;
  28. if (notificationOptionProvider != null)
  29. {
  30. notificationPlayable.GetBehaviour().AddNotification((double)time, notif, notificationOptionProvider.flags);
  31. }
  32. else
  33. {
  34. notificationPlayable.GetBehaviour().AddNotification((double)time, notif);
  35. }
  36. }
  37. return notificationPlayable;
  38. }
  39. public static bool TrackTypeSupportsNotifications(Type type)
  40. {
  41. var binding = (TrackBindingTypeAttribute)Attribute.GetCustomAttribute(type, typeof(TrackBindingTypeAttribute));
  42. return binding != null &&
  43. (typeof(Component).IsAssignableFrom(binding.type) ||
  44. typeof(GameObject).IsAssignableFrom(binding.type));
  45. }
  46. }
  47. }