美文网首页
[Unity] Playables学习整理 - 3(Playab

[Unity] Playables学习整理 - 3(Playab

作者: _Walker__ | 来源:发表于2023-04-24 19:46 被阅读0次

    1、void OnPlayableCreate(Playables.Playable playable)

    This function is called when the Playable that owns the PlayableBehaviour is created.

      当前PlayableBehaviour所属的Playable被创建时给出通知。

    2、void OnGraphStart(Playables.Playable playable)

    This function is called when the PlayableGraph that owns this PlayableBehaviour starts.
    OnGraphStart is called when the graph starts playing, or on the first invocation of PlayableGraph.Evaluate. Each call to OnGraphStart is paired with OnGraphStop.

      PlayableBehaviour所在的PlayableGraph开始播放的时候,触发通知。或者第一次执行PlayableGraph.Evaluate时也会触发。OnGraphStart跟OnGraphStop总是配对的。

    3、void OnBehaviourPlay(Playables.Playable info)

    This function is called when the Playable play state is changed to PlayState.Playing.

      当playable.GetPlayState()切换为PlayState.Playing时,触发通知。

    4、void PrepareData(Playables.Playable playable, Playables.FrameData info)

    This function is called during the PrepareData phase of the PlayableGraph.
    PrepareData is called as long as the playable is delayed.

      【这个接口完全不知道是干啥的,只能推测它的位置】

    5、void PrepareFrame(Playables.Playable playable, Playables.FrameData info)

    This function is called during the PrepareFrame phase of the PlayableGraph.
    PrepareFrame should be used to do topological modifications, change connection weights, time changes , etc.

      PlayableGraph进入PrepareFrame阶段时调用该方法。这个时机用来做下面这些事情:

    • 修改Playable节点的拓扑结构
    • 修改连接的权重
    • 修改时间

    6、void ProcessFrame(Playables.Playable playable, Playables.FrameData info, object playerData)

    This function is called during the ProcessFrame phase of the PlayableGraph.
    ProcessFrame is the stage at which your Playable does its work.
    This method is called for each frame when a Playable plays and is connected, directly or indirectly, to a ScriptPlayableOutput.

      PlayableGraph进入ProcessFrame阶段时调用该方法。
      只要播放中的Playable直接或者间接关联到ScriptPlayableOutput,该方法就会被每帧调用。

    7、void OnBehaviourPause(Playables.Playable playable, Playables.FrameData info)

    This method is invoked when one of the following situations occurs:
    The effective play state during traversal is changed to PlayState.Paused. This state is indicated by FrameData.effectivePlayState.
    The PlayableGraph is stopped while the playable play state is Playing. This state is indicated by PlayableGraph.IsPlaying returning true.

      当下面情况出现时,方法被触发:

    • 播放状态切换为PlayState.Paused:可以用FrameData.effectivePlayState识别
    • PlayableGraph停止播放:PlayableGraph.IsPlaying == true表示

    8、void OnGraphStop(Playables.Playable playable)

    This function is called when the PlayableGraph that owns this PlayableBehaviour stops.
    OnGraphStop is called when Unity stops playing the owning graph, and is guaranteed to always and only be called if OnGraphStart has been called. If the graph has been only been manually evaluated, OnGraphStop will be called prior to destroy.

      当Unity停止播放PlayableGraph时,触发通知。且只有OnGraphStart被执行过,才会该方法。

    9、void OnPlayableDestroy(Playables.Playable playable)

    This function is called when the Playable that owns the PlayableBehaviour is destroyed.
    The playable can be destroyed with PlayableExtensions.Destroy.

      PlayableBehaviour所属的Playable被销毁时,触发通知。
      可以使用PlayableExtensions.Destroy销毁Playable。


      上面的周期函数,可以按下面的执行顺序进行分组。每一组内,都会遍历执行完所有PlayableBehaviour,然后才进入下一组。

    1. OnPlayableCreate
    2. OnGraphStart、OnBehaviourPlay
    3. PrepareData
    4. PrepareFrame
    5. ProcessFrame
    6. OnBehaviourPause
    7. OnGraphStop、OnPlayableDestroy

    特殊情况,当PlayableDirector执行Pause会出现如下组合(Resume恢复的组合就是上面的2):

    • OnBehaviourPause、OnGraphStop

    相关文章

      网友评论

          本文标题:[Unity] Playables学习整理 - 3(Playab

          本文链接:https://www.haomeiwen.com/subject/kygujdtx.html