Y
yuanjiashun

  • il y a 5 jours
  • Inscrit 15 nov. 2021
  • 感谢您回复我们。 每个“TrackEntry”没有可用的直接回调,每帧都会调用它。

    可用的 TrackEntry 回调(可在各个 TrackEntry 和所有条目的 AnimationState 处使用)如下所述:
    https://zh.esotericsoftware.com/spine-unity#%E5%A4%84%E7%90%86AnimationStates%E4%BA%8B%E4%BB%B6
    和这里:
    http://esotericsoftware.com/spine-api-reference#AnimationStateListener-start
    您可以使用这些回调通过“trackEntry.Start”注册所需的方法,并通过“trackEntry.End”结束调用您的回调。
    在“SkeletonAnimation”中每帧调用的合适回调是“SkeletonAnimation.BeforeApply”和“SkeletonAnimation.UpdateLocal”,如此处

    void Start(){
         TrackEntry trackEntry = AnimationState.AddAnimation(..);
         trackEntry.Start += (entry) => { SkeletonAnimation.UpdateLocal += EveryFrameCallback; };
         trackEntry.End += (entry) => { SkeletonAnimation.UpdateLocal -= EveryFrameCallback; };
    }
    
    void EveryFrameCallback (ISkeletonAnimation skeletonAnimation) {
         Debug.Log("your callback called");
    }

    当然,您可以相应地修改源代码,并自己添加一个回调方法,类似于其他回调委托,如“Start”、“End”等。



    Thanks for getting back to us. There is no direct callback available per TrackEntry which is called every frame.

    The available TrackEntry callbacks (available at individual TrackEntry, and AnimationState for all entries) are described here:
    https://zh.esotericsoftware.com/spine-unity#%E5%A4%84%E7%90%86AnimationStates%E4%BA%8B%E4%BB%B6
    and here:
    http://esotericsoftware.com/spine-api-reference#AnimationStateListener-start
    You could use these callbacks to register your desired method with trackEntry.Start and end calling your callback with trackEntry.End.
    Suitable callbacks which are called every frame at SkeletonAnimation are SkeletonAnimation.BeforeApply and SkeletonAnimation.UpdateLocal, as described here.

    void Start () {
    	TrackEntry trackEntry = animationState.AddAnimation(..);
    	trackEntry.Start += (entry) => { skeletonAnimation.UpdateLocal += EveryFrameCallback; };
    	trackEntry.End += (entry) => { skeletonAnimation.UpdateLocal -= EveryFrameCallback; };
    }
    
    void EveryFrameCallback (ISkeletonAnimation skeletonAnimation) {
        Debug.Log("your callback called");
    }

    You could of course modify the source code accordingly and add a callback method yourself analogous to the other callback delegates like Start, End, and so on.