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 GetInfoByName(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); XMLLoader <XMLDataAnimations> obj = LuaScriptMgr.GetNetObject <XMLLoader <XMLDataAnimations> >(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 2); XMLDataAnimations o = obj.GetInfoByName(arg0); LuaScriptMgr.PushObject(L, o); return(1); }
static int GetInfoById(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); XMLLoader <XMLDataAnimations> obj = LuaScriptMgr.GetNetObject <XMLLoader <XMLDataAnimations> >(L, 1); int arg0 = (int)LuaScriptMgr.GetNumber(L, 2); XMLDataAnimations o = obj.GetInfoById(arg0); LuaScriptMgr.PushObject(L, o); return(1); }
static int get_NextAnim(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); if (o == null) { LuaDLL.luaL_error(L, "unknown member name NextAnim"); } XMLDataAnimations obj = (XMLDataAnimations)o; LuaScriptMgr.Push(L, obj.NextAnim); return(1); }
static int set_NextAnim(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); if (o == null) { LuaDLL.luaL_error(L, "unknown member name NextAnim"); } XMLDataAnimations obj = (XMLDataAnimations)o; obj.NextAnim = LuaScriptMgr.GetString(L, 3); return(0); }
static int set_Loop(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); if (o == null) { LuaDLL.luaL_error(L, "unknown member name Loop"); } XMLDataAnimations obj = (XMLDataAnimations)o; obj.Loop = (int)LuaScriptMgr.GetNumber(L, 3); return(0); }