BasicScriptPlayable.cs 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Playables;
  5. namespace UnityEngine.Timeline
  6. {
  7. /// <summary>
  8. /// This class is deprecated. It is recommended to use Playable Asset and Playable Behaviour derived classes instead.
  9. /// </summary>
  10. [Serializable]
  11. [Obsolete("For best performance use PlayableAsset and PlayableBehaviour.")]
  12. public class BasicPlayableBehaviour : ScriptableObject, IPlayableAsset, IPlayableBehaviour
  13. {
  14. public BasicPlayableBehaviour() {}
  15. /// <summary>
  16. /// The playback duration in seconds of the instantiated Playable.
  17. /// </summary>
  18. public virtual double duration { get { return PlayableBinding.DefaultDuration; } }
  19. /// <summary>
  20. ///A description of the outputs of the instantiated Playable.
  21. /// </summary>
  22. public virtual IEnumerable<PlayableBinding> outputs { get { return PlayableBinding.None; } }
  23. /// <summary>
  24. /// <para>This function is called when the PlayableGraph that owns this PlayableBehaviour starts.</para>
  25. /// </summary>
  26. /// <param name="playable">The Playable that owns the current PlayableBehaviour.</param>
  27. public virtual void OnGraphStart(Playable playable) {}
  28. /// <summary>
  29. /// <para>This function is called when the PlayableGraph that owns this PlayableBehaviour stops.</para>
  30. /// </summary>
  31. /// <param name="playable">The Playable that owns the current PlayableBehaviour.</param>
  32. public virtual void OnGraphStop(Playable playable) {}
  33. /// <summary>
  34. /// <para>This function is called when the Playable that owns the PlayableBehaviour is created.</para>
  35. /// </summary>
  36. /// <param name="playable">The Playable that owns the current PlayableBehaviour.</param>
  37. public virtual void OnPlayableCreate(Playable playable) {}
  38. /// <summary>
  39. /// <para>This function is called when the Playable that owns the PlayableBehaviour is destroyed.</para>
  40. /// </summary>
  41. /// <param name="playable">The Playable that owns the current PlayableBehaviour.</param>
  42. public virtual void OnPlayableDestroy(Playable playable) {}
  43. /// <summary>
  44. /// <para>This function is called when the Playable play state is changed to Playables.PlayState.Playing.</para>
  45. /// </summary>
  46. /// <param name="playable">The Playable that owns the current PlayableBehaviour.</param>
  47. /// <param name="info">A FrameData structure that contains information about the current frame context.</param>
  48. public virtual void OnBehaviourPlay(Playable playable, FrameData info) {}
  49. /// <summary>
  50. /// <para>This function is called when the Playable play state is changed to Playables.PlayState.Paused.</para>
  51. /// </summary>
  52. /// <param name="playable">The Playable that owns the current PlayableBehaviour.</param>
  53. /// <param name="info">A FrameData structure that contains information about the current frame context.</param>
  54. public virtual void OnBehaviourPause(Playable playable, FrameData info) {}
  55. /// <summary>
  56. /// <para>This function is called during the PrepareFrame phase of the PlayableGraph.</para>
  57. /// </summary>
  58. /// <param name="playable">The Playable that owns the current PlayableBehaviour.</param>
  59. /// <param name="info">A FrameData structure that contains information about the current frame context.</param>
  60. public virtual void PrepareFrame(Playable playable, FrameData info) {}
  61. /// <summary>
  62. /// <para>This function is called during the ProcessFrame phase of the PlayableGraph.</para>
  63. /// </summary>
  64. /// <param name="playable">The Playable that owns the current PlayableBehaviour.</param>
  65. /// <param name="info">A FrameData structure that contains information about the current frame context.</param>
  66. /// <param name="playerData">The user data of the ScriptPlayableOutput that initiated the process pass.</param>
  67. public virtual void ProcessFrame(Playable playable, FrameData info, object playerData) {}
  68. /// <summary>
  69. /// Implement this method to have your asset inject playables into the given graph.
  70. /// </summary>
  71. /// <param name="graph">The graph to inject playables into.</param>
  72. /// <param name="owner">The game object which initiated the build.</param>
  73. /// <returns>The playable injected into the graph, or the root playable if multiple playables are injected.</returns>
  74. public virtual Playable CreatePlayable(PlayableGraph graph, GameObject owner)
  75. {
  76. return ScriptPlayable<BasicPlayableBehaviour>.Create(graph, this);
  77. }
  78. }
  79. }