SignalEmitter.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.Playables;
  4. namespace UnityEngine.Timeline
  5. {
  6. /// <inheritdoc cref="UnityEngine.Timeline.IMarker" />
  7. /// <summary>
  8. /// Marker that emits a signal to a SignalReceiver.
  9. /// </summary>
  10. /// A SignalEmitter emits a notification through the playable system. A SignalEmitter is used with a SignalReceiver and a SignalAsset.
  11. /// <seealso cref="UnityEngine.Timeline.SignalAsset"/>
  12. /// <seealso cref="UnityEngine.Timeline.SignalReceiver"/>
  13. [Serializable]
  14. [CustomStyle("SignalEmitter")]
  15. [ExcludeFromPreset]
  16. public class SignalEmitter : Marker, INotification, INotificationOptionProvider
  17. {
  18. [SerializeField] bool m_Retroactive;
  19. [SerializeField] bool m_EmitOnce;
  20. [SerializeField] SignalAsset m_Asset;
  21. /// <summary>
  22. /// Use retroactive to emit the signal if playback starts after the SignalEmitter time.
  23. /// </summary>
  24. public bool retroactive
  25. {
  26. get { return m_Retroactive; }
  27. set { m_Retroactive = value; }
  28. }
  29. /// <summary>
  30. /// Use emitOnce to emit this signal once during loops.
  31. /// </summary>
  32. public bool emitOnce
  33. {
  34. get { return m_EmitOnce; }
  35. set { m_EmitOnce = value; }
  36. }
  37. /// <summary>
  38. /// Asset representing the signal being emitted.
  39. /// </summary>
  40. public SignalAsset asset
  41. {
  42. get { return m_Asset; }
  43. set { m_Asset = value; }
  44. }
  45. PropertyName INotification.id
  46. {
  47. get
  48. {
  49. if (m_Asset != null)
  50. {
  51. return new PropertyName(m_Asset.name);
  52. }
  53. return new PropertyName(string.Empty);
  54. }
  55. }
  56. NotificationFlags INotificationOptionProvider.flags
  57. {
  58. get
  59. {
  60. return (retroactive ? NotificationFlags.Retroactive : default(NotificationFlags)) |
  61. (emitOnce ? NotificationFlags.TriggerOnce : default(NotificationFlags)) |
  62. NotificationFlags.TriggerInEditMode;
  63. }
  64. }
  65. }
  66. }