Exemplo n.º 1
0
        private void LoadLuaSuccessCallback(string assetName, object asset, float duration, object userData)
        {
            LuaFileInfo luaFileInfo = (LuaFileInfo)userData;

            if (luaFileInfo == null)
            {
                throw new GameFrameworkException("Load lua file info is invalid.");
            }

            TextAsset textAsset = asset as TextAsset;

            if (textAsset == null)
            {
                Log.Warning("lua asset '{0}' is invalid.", assetName);
                return;
            }

            luaFileInfo.Bytes = textAsset.bytes;

            if (!m_CacheLuaDict.ContainsKey(luaFileInfo.LuaName))
            {
                m_CacheLuaDict.Add(luaFileInfo.LuaName, luaFileInfo);
//                Log.Info("Load lua file '{0}' OK.", luaFileInfo.LuaName);
            }
            else
            {
                m_CacheLuaDict[luaFileInfo.LuaName] = luaFileInfo;
//                Log.Warning("Already exist lua file '{0}'.", luaFileInfo.LuaName);
            }

            if (luaFileInfo.IsIndependent)
            {
                m_LuaEvn.DoString(luaFileInfo.Bytes, luaFileInfo.LuaName, m_ScriptTable);
            }
        }
Exemplo n.º 2
0
        public void LoadLua(string luaName, LoadType loadType, bool isIndependent)
        {
            LuaFileInfo luaFileInfo = new LuaFileInfo(luaName, loadType, isIndependent);

            m_ResourceManager.LoadAsset(luaFileInfo.AssetName, Constant.AssetPriority.LuaAsset,
                                        this.m_LoadLuaFileCallbacks, luaFileInfo);
        }
Exemplo n.º 3
0
        private void LoadLuaFailureCallback(string assetName, LoadResourceStatus status, string errorMessage, object userData)
        {
            LuaFileInfo luaFileInfo = (LuaFileInfo)userData;

            if (luaFileInfo == null)
            {
                throw new GameFrameworkException("Load lua file info is invalid.");
            }
            string str = Utility.Text.Format("Load lua file failure, asset name '{0}', status '{1}', error message '{2}'.", (object)assetName, (object)status.ToString(), (object)errorMessage);
            //TODO:处理载入错误
//            if (this.m_LoadDataTableFailureEventHandler == null)
//                throw new GameFrameworkException(str);
        }