- Editado
スロット表示、非表示の制御について
Unityでランタイム3.8を使用しています。
スロット表示、非表示を、コードでコントロールする際に、現状ではデータのキーが優先されて、キーがある場合には強制表示されるようです。
任意に、コードを優先するか、データを優先するか、コード上から決められるようにしたいのですが、良い方法はありませんか?
実現したいものはこちらです。
キャラクタを2つ表示して、コードのコントロールで片方を消したい時、キャラクタの顔にスロット表示、メッシュキーを入れていると、そのパーツだけ表示が居残ってしまう。パーツをすべて消したい。
再生しているアニメーションが、コードから設定した添付ファイルの表示を上書きしていることを意味していると思います。
アニメーションは SkeletonAnimation.Update()
のフレームごとに適用されるため、それ以前に設定された状態が上書きされることに注意してください。
したがって、コードを介してスロット状態を適用するには、次のいずれかを実行します。
a)不要な場合は、アニメーションに添付ファイルの状態を入力しないでください。 すべてにキーを設定するのではなく、アニメーションによって変更されることを明記してください。
b)アニメーションが適用された後に呼び出される SkeletonAnimation.UpdateLocal
コールバックを使用します。 UpdateLocal
デリゲートをサブスクライブする方法については、このドキュメントセクションを参照してください。
I assume that you mean that the animations you are playing are overriding attachment visibility that you set from code.
Please note that animations are applied every frame in SkeletonAnimation.Update()
, so it will override any state set before that.
So in order to have slot state applied via code, either:
a) Do not key the attachment state in your animation, if it is unnecessary. Do not key everything, just state that shall be changed by the animation.
b) Use the SkeletonAnimation.UpdateLocal
callback, which is called after the animations have been applied. Please see this documentation section on how to subscribe to the UpdateLocal
delegate.
Thanks for the reply.
同じことを聞くようで恐縮だが
I'm afraid I'm going to ask you the same thing.
アタッチメントキーを使ったら、コードではコントロールできない?
So,
If I'm using attachment key, can't I control it with code?
Is that correct?
将来的に選択できるようにならないか?
Will we be able to choose in the future?
642 / 5000
Translation results
キーで添付ファイルを設定する場合は、コードで設定できます。 フレームごとに設定するだけで、アニメーションが適用された後です。 これは私がオプション(b)で提案したものです:
b)アニメーションが適用された後に呼び出される SkeletonAnimation.UpdateLocal
コールバックを使用します。 UpdateLocal
デリゲートをサブスクライブする方法については、このドキュメントのセクションを参照してください。
//デリゲートメソッド
void AfterUpdateLocal(ISkeletonAnimation anim){
//ここに添付ファイルを設定します
}
//デリゲートメソッドを登録します
void Start(){
skeletonAnimation.UpdateLocal- = AfterUpdateLocal;
skeletonAnimation.UpdateLocal + = AfterUpdateLocal;
}
If you set the attachment via key, you can set it via code. You just have to set it every frame, and after animations are applied. This is what I suggested via option (b):
b) Use the SkeletonAnimation.UpdateLocal
callback, which is called after the animations have been applied. Please see this documentation section on how to subscribe to the UpdateLocal
delegate.
// your delegate method
void AfterUpdateLocal (ISkeletonAnimation anim) {
// set attachments here
}
// register your delegate method
void Start() {
skeletonAnimation.UpdateLocal -= AfterUpdateLocal;
skeletonAnimation.UpdateLocal += AfterUpdateLocal;
}
Thank you.
I'll try it.