一般来说,SkeletonMecanim
不会被自定义应用的 AnimationState 覆盖,但应该可以这样做。
你从哪里调用你在下面提到的代码?
如果你在 Update()
或 LateUpdate()
中调用你的代码,你应该在回调方法之一中调用它,例如 通过在 UpdateLocal
注册您的方法。
void Awake() {
skeletonMecanim.UpdateLocal += ApplyYourAnimationState;
...}
这样,您的方法将在应用 Mecanim 状态之后和在调用 skeleton.UpdateWorldTransform()
之前被调用。
// SKeletonMecanim.cs 中的代码,在 SkeletonMecanim.Update() 中调用:
..
translator.Apply(skeleton);
..
_UpdateLocal(this);
..
skeleton.UpdateWorldTransform();
..
In general SkeletonMecanim
is not intended to be overridden by a custom applied AnimationState, nevertheless it should be possible to do so.
From where are you calling your code that you have mentioned below?
If you are calling your code in Update()
or LateUpdate()
, you should instead be calling it in one of the callback methods, e.g. by registering your method at UpdateLocal
.
void Awake() {
skeletonMecanim.UpdateLocal += ApplyYourAnimationState;
...}
This way your methods will be called after the Mecanim state was applied, and before skeleton.UpdateWorldTransform()
is called.
// code in SKeletonMecanim.cs, called in SkeletonMecanim.Update():
..
translator.Apply(skeleton);
..
_UpdateLocal(this);
..
skeleton.UpdateWorldTransform();
..