Esempio n. 1
0
        private void UF_LuaBaseStart(GLuaState luastate)
        {
            if (luastate != null)
            {
                string toluaroot = LuaRoot;

                string[] luafiles =
                {
                    "Main.lua",

                    "Mathf.lua",        //ToLua/UnityEngine/Mathf.lua
                    "Vector3.lua",      //ToLua/UnityEngine/Vector3.lua
                    "Quaternion.lua",   //ToLua/UnityEngine/Quaternion.lua
                    "Vector2.lua",      //ToLua/UnityEngine/Vector2.lua
                    "Vector4.lua",      //ToLua/UnityEngine/Vector4.lua
                    "Color.lua",        //ToLua/UnityEngine/Color.lua
                    "Ray.lua",          //ToLua/UnityEngine/Ray.lua
                    "Bounds.lua",       //ToLua/UnityEngine/Bounds.lua
                    "RaycastHit.lua",   //ToLua/UnityEngine/RaycastHit.lua
                    "Touch.lua",        //ToLua/UnityEngine/Touch.lua
                    "LayerMask.lua",    //ToLua/UnityEngine/LayerMask.lua
                    "Plane.lua",        //ToLua/UnityEngine/Plane.lua
                    "TypeOf.lua",       //ToLua/System/TypeOf.lua
                    "ValueType.lua",    //ToLua/System/ValueType.lua
                    "BindingFlags.lua", //ToLua/System/BindingFlags.lua
                };

                int top = m_Luastate.LuaGetTop();
                for (int k = 0; k < luafiles.Length; k++)
                {
                    var assetinfo = AssetDataBases.UF_GetAssetInfo(luafiles[k]);
                    if (assetinfo == default(AssetDataBases.AssetFileInfo))
                    {
                        throw new LuaException(string.Format("Can not get lua file[{0}] in AssetDataBase,Load file failed!", luafiles[k]), LuaException.GetLastError());
                    }
                    if (!UF_DoFile(m_Luastate.LuaGetL(), assetinfo.path, Path.GetFileNameWithoutExtension(assetinfo.name)))
                    {
                        string err = m_Luastate.LuaToString(-1);
                        m_Luastate.LuaSetTop(top);
                        throw new LuaException(err, LuaException.GetLastError());
                    }
                }
                m_Luastate.LuaSetTop(top);

                //打开基础库
                LuaUnityLibs.OpenLuaLibs(luastate.LuaGetL());

                luastate.Start();
            }
        }
Esempio n. 2
0
        //审核模式下尝试加载替换资源文件
        //替换资源固有前缀为"re_"
        private AssetBundleData UF_TryGetRebundleAsset(string bundleName)
        {
            AssetBundleData ret = null;
            //固定加入前缀
            string rebundleName = string.Format("re_{0}", bundleName);
            var    afi          = AssetDataBases.UF_GetAssetInfo(rebundleName);

            if (afi == null || string.IsNullOrEmpty(afi.path))
            {
                return(null);
            }
            string path = afi.path;

            if (File.Exists(path))
            {
                //rebundle 资源字节不加密不偏移
                ret = AssetBundleData.UF_LoadFromFile(bundleName, path, LoadAssetBundleOptions.UNLOAD_IN_NO_REF);
                Debugger.UF_Log(string.Format("Try Load Replacement AssetBundle[{0}] Success", bundleName));
            }
            return(ret);
        }
Esempio n. 3
0
        private AssetBundleData UF_LoadAssetBundleDataFromFile(string bundleName, LoadAssetBundleOptions flag)
        {
            AssetBundleData abd = null;

            //审核模式读取Raw中资源,并且需要resKey偏移
            if (GlobalSettings.IsAppCheck && GlobalSettings.IsRawAsset)
            {
                //尝试加载替换资源
                abd = UF_TryGetRebundleAsset(bundleName);
                if (abd != null)
                {
                    return(abd);
                }
                //
                var afi = AssetDataBases.UF_GetAssetInfo(bundleName);
                if (afi == null || string.IsNullOrEmpty(afi.path))
                {
                    Debugger.UF_Error(string.Format("bundleName:[{0}] AssetDataBases.UF_GetAssetInfo failed", bundleName));
                    return(null);
                }
                //需要写入文件偏移
                abd = AssetBundleData.UF_LoadFromStream(bundleName, afi.path, flag, GlobalSettings.EncBKey, GlobalSettings.ResBKey);
            }
            else
            {
                var afi = AssetDataBases.UF_GetAssetInfo(bundleName);
                if (afi == null || string.IsNullOrEmpty(afi.path))
                {
                    Debugger.UF_Error(string.Format("bundleName:[{0}] AssetDataBases.UF_GetAssetInfo failed", bundleName));
                    return(null);
                }
                //abd = AssetBundleData.LoadFromFile(bundleName, afi.path, flag);
                //需要管理Stream随AssetBundle 的释放去释放,否则Strem并不会自己释放导致IO读写错误
                abd = AssetBundleData.UF_LoadFromStream(bundleName, afi.path, flag, GlobalSettings.EncBKey, 0);
            }
            return(abd);
        }