Ingen beskrivning
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.

SignalEmitter.cs 2.2KB

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