【Model&Animation】
1、FBX文件是一个完整的模型,通常内含Mesh,Material,Texture,Animation,即内含构成一个完成GameObject所需要的一切组件。可以通过以下代码来引用。
1 //动画名称 2 public const string ANIM_NAME0="idle"; 3 public const string ANIM_NAME1="run"; 4 public const string ANIM_NAME2="walk"; 5 public const string ANIM_NAME3="jump_pose"; 6 //模型对象 7 private GameObject obj = null; 8 9 void Start () 10 { 11 //获取模型动画 12 obj = GameObject.Find("Constructor"); 13 //设置动画播放类型为循环 14 obj.animation.wrapMode = WrapMode.Loop; 15 } 16 17 void Update () 18 { 19 //按键后播放不同动画 20 if (Input.GetKeyDown (KeyCode.A)) 21 { 22 obj.animation.Play(ANIM_NAME0); 23 } 24 if (Input.GetKeyDown (KeyCode.B)) 25 { 26 obj.animation.Play(ANIM_NAME1); 27 } 28 if (Input.GetKeyDown (KeyCode.C)) 29 { 30 obj.animation.Play(ANIM_NAME2); 31 } 32 if (Input.GetKeyDown (KeyCode.D)) 33 { 34 obj.animation.Play(ANIM_NAME3); 35 } 36 }