using UnityEngine; using System.Collections; public class UGUIChangeCostume : MonoBehaviour { public GameObject face0; // 通常衣装 public GameObject face1; // ハロウィン衣装 public GameObject body0; public GameObject body1; void Start(){ face0.SetActive (true); face1.SetActive (!true); body0.SetActive (true); body1.SetActive (!true); } // 衣装チェンジ public void OnClickSwapCostumeButton(){ face0.SetActive (!face0.activeSelf); face1.SetActive (!face1.activeSelf); body0.SetActive (!body0.activeSelf); body1.SetActive (!body1.activeSelf); } }
したいこと:ボタンを押すとユニティちゃんの衣装を通常からハロウィンに変更したい。アニメーションは維持したい。
AnimatorControllerとAvatarを引き渡すだけだとアニメーションが最初から再生されてしまう。Animatorの現在の状態も引き渡す方法がわからなかったので、2つのモデルを同じモーションで動かしておいて、片方の表示を消すという方法で、踊りを継続させながら衣装チェンジをすることができた。