public void PlayAnimation(string animName) { if (string.IsNullOrEmpty(animName)) { return; } if (!XMLManager.Animations.Data.ContainsKey(animName)) { return; } m_listSprite = new List <Sprite>(); m_animData = XMLManager.Animations.GetInfoByName(animName); TextAsset ta = ResourcesManager.Instance.Load <TextAsset>(animName); if (ta == null) { Debugging.LogError("PlayAnimation: animName = " + animName); return; } string[] spritePaths = ta.text.Trim().Split('\n'); for (int i = 0; i < spritePaths.Length; i++) { string path = spritePaths[i].Trim(); Sprite sprite = ResourcesManager.Instance.Load <Sprite>(path); if (sprite == null) { m_listSprite.Clear(); Debugging.LogError("PlayAnimation: animName = " + animName + ", spritePath = " + path); continue; } m_listSprite.Add(sprite); } if (m_listSprite.Count == 0) { Debugging.LogError("PlayAnimation: animName = " + animName); return; } this.animName = animName; this.isPlaying = true; this.isPause = false; m_animCompleteEvent = null; m_timeTick = 0; this.animIndex = 0; if (m_spriteRenderer == null) { m_spriteRenderer = gameObject.AddComponent <SpriteRenderer>(); } m_spriteRenderer.sprite = m_listSprite[animIndex]; }
static int PlayAnimation(IntPtr L) { int count = LuaDLL.lua_gettop(L); Type[] types1 = { typeof(AnimationComponent), typeof(string), typeof(LuaInterface.LuaFunction) }; Type[] types2 = { typeof(AnimationComponent), typeof(string), typeof(CallBack.CallBackDelegate) }; if (count == 2) { AnimationComponent obj = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 2); obj.PlayAnimation(arg0); return(0); } else if (count == 3 && LuaScriptMgr.CheckTypes(L, types1, 1)) { AnimationComponent obj = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1); string arg0 = LuaScriptMgr.GetString(L, 2); LuaFunction arg1 = LuaScriptMgr.GetLuaFunction(L, 3); obj.PlayAnimation(arg0, arg1); return(0); } else if (count == 3 && LuaScriptMgr.CheckTypes(L, types2, 1)) { AnimationComponent obj = LuaScriptMgr.GetNetObject <AnimationComponent>(L, 1); string arg0 = LuaScriptMgr.GetString(L, 2); CallBack.CallBackDelegate arg1 = LuaScriptMgr.GetNetObject <CallBack.CallBackDelegate>(L, 3); obj.PlayAnimation(arg0, arg1); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: AnimationComponent.PlayAnimation"); } return(0); }
public void PlayAnimation(string animName, CallBack.CallBackDelegate animCompleteEvent) { PlayAnimation(animName); m_animCompleteEvent = animCompleteEvent; }