//----------------------------------------------------------------------- string GetAnimatorClip(eUIAniType type) { string clipName = ""; //switch(type) //{ //case eUIAniType.IconPoint_01: clipName = "UI/UIAnim/Icon_Point_01"; break; //case eUIAniType.IconPoint_02_Num: clipName = "UI/UIAnim/Icon_Point_02_Num"; break; //case eUIAniType.Messege_9Point: clipName = "UI/UIAnim/Messege_9Point"; break; //case eUIAniType.Messege_BG_01: clipName = "UI/UIAnim/Messege_BG_01"; break; //case eUIAniType.Messege_BG_02: clipName = "UI/UIAnim/Messege_BG_02"; break; //case eUIAniType.Messege_BG_03: clipName = "UI/UIAnim/Messege_BG_03"; break; //case eUIAniType.Messege_Player1Win: clipName = "UI/UIAnim/Messege_Player1Win"; break; //case eUIAniType.Messege_RoundStart: clipName = "UI/UIAnim/Messege_RoundStart"; break; //case eUIAniType.Box_Bottom: clipName = "UI/UIAnim/Box_Bottom"; break; //case eUIAniType.Box_Glow: clipName = "UI/UIAnim/Box_Glow"; break; //case eUIAniType.Box_Result_Text: clipName = "UI/UIAnim/Box_Result_Text"; break; //case eUIAniType.Trophy: clipName = "UI/UIAnim/Trophy_01"; break; //case eUIAniType.Perfect_Text_01: clipName = "UI/UIAnim/Perfect_Text_01"; break; //case eUIAniType.Score_Messege: clipName = "UI/UIAnim/Score_Messege"; break; //} return(clipName); }
//----------------------------------------------------------------------- public void PlayAnimator(eUIAniType type, GameObject obj, string LayerType = "UIPlay") { Animator ani = obj.GetComponent <Animator>(); if (ani == null) { ani = obj.AddComponent <Animator>(); } if (ani.runtimeAnimatorController == null) { string loadPath = GetAnimatorClip(type); RuntimeAnimatorController clip = Resources.Load(loadPath, typeof(RuntimeAnimatorController)) as RuntimeAnimatorController; if (clip == null) { return; } ani.runtimeAnimatorController = clip; } ani.Rebind(); ani.Play(LayerType); }