- Modifié
Unity セパレートが上手く行かない
セパレートした際、Slotが分割されているのにも関わらず、Meshが正しく別れておらず困っています。
Skeleton Render Separatorのインスペクタ情報は間違っていないと思うのですが、
アニメーションを切り替えると、セパレートしたMeshが何故かインスペクタ上から無くなる事があるので、表示が上手くいきません。
いい方法があれば教えて頂きたいです。
やりたいこと
1体のキャラクターをSpineとして作成しています。
このSpineは前向き絵と後ろ向き状態の絵がそれぞれあるので、
SpineをUnityランタイムで生成した時に前向き絵の左腕、体、後ろ向き絵の右腕の3つにセパレートしています。
なので、キャラクターが前向きの際は体と左腕が分割されている状態、キャラクターが後ろ向きの際は体と右腕が分割されている状態にしたいです。
やってみたこと
前向き絵の左腕のSlot名を「SE_l_arm_front」
後ろ向き絵の右腕のSlot名を「SE_r_arm_back」
としました。
SlotリストをSlotの頭文字で分割する「skeletonAnimation.FindAndApplySeparatorSlots関数」を使いたかったため、頭文字に「SE」を付けています。
以下のspine-unity Runtime Documentationを参考にセパレートしました。
http://ja.esotericsoftware.com/spine-unity#SkeletonRenderSeparator
この状態で前向きのアニメーションを再生すると正しく「SE_l_arm_front」が分割されているのが確認できましたが、
後ろ向きアニメーションを再生すると「SE_r_arm_back」が分割されていませんでした。
以下、インスペクタ等、現在の情報です。
セパレートされたSlot
SE_l_arm_front
セパレートされなかったSlot
SE_r_arm_back
Slot内容
SkeletonRenderSeparatorのインスペクタ
前向きでのPartsRenderersの内容
0
1
2
後ろ向きでのPartsRenderersの内容
0
1
2
セパレートをスクリプト上で行うためのスクリプト
※ startsWithSlotName = "SE"
private void EnableSeparator(string startsWithSlotName)
{
// separatorSlotを予め初期化
skeletonAnimation.separatorSlots.Clear();
// 特定の文字列で始まるSlotを分割する
skeletonAnimation.FindAndApplySeparatorSlots(startsWithSlotName, false, true);
// SkeletonRenderSeparatorを初期化する
SkeletonRenderSeparator skeletonRenderSeparator = SkeletonRenderSeparator.AddToSkeletonRenderer(skeletonAnimation);
// Separatorを有効にする
skeletonRenderSeparator.enabled = true;
}
後ろ向きのアニメーションを再生した際、セパレータオブジェクト「2」のMeshがNoneになる点が気になります。
ご教授お願いいたします。
詳細な説明をありがとう。
separatorSlots
は現在の描画順序の特定のポイントでレンダリングを分割することに注意してください。 セパレータスロットが描画順序の正しい場所にあることを確認しますか? スロットを示すスクリーンショットでは、上部に「SE_l_arm_front」が非常に高く、下部に「SE_r_arm_back」が表示されています。セパレータをより中央に配置するつもりでしたか?
コードを使用して分離を適用せず、UnityエディターでSkeletonRenderSeparator
Componentを手動でセットアップした場合、分離は正しく機能しますか?
Thanks for the detailed description.
Please note that the separatorSlots
split rendering at a certain point in the current draw order. Are you sure that your separator slots are in the right place in the draw order? The screenshot showing your slots lists SE_l_arm_front
very high at the top and SE_r_arm_back
at the very bottom - did you perhaps intend to place the separators more in the center?
Does separation work correctly when you do not use code to apply separation, but instead setup the SkeletonRenderSeparator
Component manually in the Unity Editor?
Haraldさん
確認と日本語翻訳ありがとうございます!
日本語での返信、すみません。
自分が考えていたSeparatorの描画順は、
SE_r_arm_back < other < SE_l_arm_front
の順になります。
理由は、腕(arm)と体(other)の間に画像(spriteRenderer)を差し込みたいからです。
なので、separateした後、sortingOrderを制御し、以下のような描画順に変える予定です。
キャラクターが後ろを向いているときの描画順
SE_r_arm_back < spriteRenderer < other
キャラクターが前を向いているときの描画順
other < spriteRenderer < SE_l_arm_front
The screenshot showing your slots lists SE_l_arm_front very high at the top and SE_r_arm_back at the very bottom - did you perhaps intend to place the separators more in the center?
自信が無いですが、「SE_r_arm_back < other < SE_l_arm_front」の順番にするのであれば、これは正しいと考えています。
Does separation work correctly when you do not use code to apply separation, but instead setup the SkeletonRenderSeparator Component manually in the Unity Editor?
やってみます!
お返事ありがとうございます。
Draw Order
のスクリーンショットをSpine EditorのHierarchy
ウィンドウで、前向きと後ろ向きの両方のアニメーションのために投稿していただけないでしょうか。
エディタのSkeletonRenderSeparator
を設定したときに問題が発生しないかどうかを教えてください。その後、問題がまだ発生していることを示す最小のUnityプロジェクトをzipパッケージとして contact@esotericsoftware.com まで送っていただけないでしょうか?
Thanks for your reply.
Could you please post a screenshot of the Draw Order
in the Hierarchy
window in the Spine Editor, for both forward and backward facing animations.
Please let us know if the problem does not occur when you setup the SkeletonRenderSeparator
in the Editor. Could you then please send us a minimal Unity project that still shows the problem as a zip package, to contact@esotericsoftware.com?
Harald さん
確認と日本語翻訳ありがとうございます!
日本語での返信、すみません。
問題は発生せず、先程解決しました!
UnityEditorで手動セットアップをしている時、SkeletonDataの「Debug Selection」を見つけました。
これを見る限り、どうやら、SeparateするためのSlot指定が1つ抜けていたようです。
Before Separator Slot Names :no:
SE_l_arm_front
SE_r_arm_back
After Separator Slot Names :yes:
SE_l_arm_front
Cuisine_back
SE_r_arm_back
なので、Separateするだけの「SE_blank」を追加し、
Separator Slot Namesを
SE_l_arm_front
SE_blank
SE_r_arm_back
にすることによって、解決しました。
詳しい返信ありがとうございます。 お知らせいただきありがとうございます。問題を解決していただき、誠にありがとうございます。
Thanks for your detailled reply. Very glad that you could resolve thye issue, thanks for letting us know!
Harald さん
お騒がせしました。こちらこそ、ご教授ありがとうございました!
詳しい説明ありがとうございます。
No need to apologize, thanks for the detailled explanations.