SignalEmitter.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. public class SignalEmitter : Marker, INotification, INotificationOptionProvider
  16. {
  17. [SerializeField] bool m_Retroactive;
  18. [SerializeField] bool m_EmitOnce;
  19. [SerializeField] SignalAsset m_Asset;
  20. /// <summary>
  21. /// Use retroactive to emit the signal if playback starts after the SignalEmitter time.
  22. /// </summary>
  23. public bool retroactive
  24. {
  25. get { return m_Retroactive; }
  26. set { m_Retroactive = value; }
  27. }
  28. /// <summary>
  29. /// Use emitOnce to emit this signal once during loops.
  30. /// </summary>
  31. public bool emitOnce
  32. {
  33. get { return m_EmitOnce; }
  34. set { m_EmitOnce = value; }
  35. }
  36. /// <summary>
  37. /// Asset representing the signal being emitted.
  38. /// </summary>
  39. public SignalAsset asset
  40. {
  41. get { return m_Asset; }
  42. set { m_Asset = value; }
  43. }
  44. PropertyName INotification.id
  45. {
  46. get
  47. {
  48. if (m_Asset != null)
  49. {
  50. return new PropertyName(m_Asset.name);
  51. }
  52. return new PropertyName(string.Empty);
  53. }
  54. }
  55. NotificationFlags INotificationOptionProvider.flags
  56. {
  57. get
  58. {
  59. return (retroactive ? NotificationFlags.Retroactive : default(NotificationFlags)) |
  60. (emitOnce ? NotificationFlags.TriggerOnce : default(NotificationFlags)) |
  61. NotificationFlags.TriggerInEditMode;
  62. }
  63. }
  64. }
  65. }