Animation
#region //控制Animation的播放
private void onAnimationGui()//(GameObject obj)
{
Animation animation = gameObject.transform.GetComponentInChildren<Animation>();
// Animator animator = obj.transform.GetComponentInChildren<Animator>();
int count = 0;
if(animation.gameObject.transform.parent.gameObject.activeSelf)
{
foreach(AnimationState _state in animation)
{
if (GUI.Button(new Rect(Vector2.up * 60*(count+1), new Vector2(150, 50)), "Play "+_state.name))
{
if(null != _state)
{
animation.enabled = true;
animation.Play(_state.name);
Debug.Log("當(dāng)前播放的是"+animation.name+"--------------"+_state.name+"----動畫");
}
}
count += 1;
Debug.Log("clips.lenght=======333333333333333333333333333333333333333333=====animation"+animation);
}
if (GUI.Button(new Rect(Vector2.up * 60*(count+1), new Vector2(150, 50)), "重置Reset"))
{
gameObject.transform.localPosition = originPos;
Debug.Log("重置回初始狀態(tài)");
}
Debug.Log("clips.lenght=======44444444444444444444444444444444444444444444444444=====");
setScaleController(count +2,animation.gameObject);
Debug.Log("clips.lenght=======44444444444444444444444444444444444444444444444444=====");
}
}
#endregion
Animator
#region //控制Animator的播放
private void onAnimatorGui()//(GameObject obj)
{
Animator animator = gameObject.transform.GetComponentInChildren<Animator>();
// Animator animator = obj.transform.GetComponentInChildren<Animator>();
if(animator.gameObject.transform.parent.gameObject.activeSelf)
{
AnimationClip[] clips = animator.runtimeAnimatorController.animationClips;
for(int i = 0;i<clips.Length;i++)
{
//根據(jù)動畫名字 添加對應(yīng)的動畫按鈕
if (GUI.Button(new Rect(Vector2.up * 60*(i+1), new Vector2(150, 50)), "Play "+clips[i].name))
{
// GUI.GUIStyle.fontSize = 60;
if(null != animator)
{
animator.enabled = true;
animator.Play(clips[i].name);
}
}
}
if (GUI.Button(new Rect(Vector2.up * 60*(clips.Length+1), new Vector2(150, 50)), "重置Reset"))
{
gameObject.transform.localPosition = originPos;
Debug.Log("重置回初始狀態(tài)");
}
setScaleController(clips.Length,animator.gameObject);
Debug.Log("clips.lenght=======44444444444444444444444444444444444444444444444444=====");
}
}
#endregion
SkeletonAnimation
#region 控制spine的播放
private void onSpineGui()
{
SkeletonAnimation spineAni = gameObject.transform.GetComponentInChildren<SkeletonAnimation>();
int count = 0;
if(spineAni.gameObject.transform.parent.gameObject.activeSelf)
{
var aa = spineAni.skeleton.data.Animations.ToArray();
for(int i = 0;i<aa.Length;i++)
{
if (GUI.Button(new Rect(Vector2.up * 60*(count+1), new Vector2(150, 50)), "Play "+aa[i].name))
{
if(null != spineAni)
{
spineAni.GetComponent<SkeletonAnimation>().enabled = true;
spineAni.state.SetAnimation(0, aa[i].name, true);
Debug.Log("當(dāng)前播放的是"+spineAni.GetComponent<SkeletonAnimation>().name+"--------------"+aa[i].name+"----動畫");
}
}
count += 1;
}
if (GUI.Button(new Rect(Vector2.up * 60*(count+1), new Vector2(150, 50)), "重置Reset"))
{
gameObject.transform.localPosition = originPos;
Debug.Log("重置回初始狀態(tài)");
}
setScaleController(count +2,spineAni.gameObject);
}
}
#endregion
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。