コード例 #1
0
ファイル: LuaFramework.cs プロジェクト: moto2002/FrameLock
        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();
            }
        }
コード例 #2
0
ファイル: AssetSystem.cs プロジェクト: moto2002/FrameLock
        internal IEnumerator UF_InitAssetSystem()
        {
#if !__EDITOR_MODE__
            //审核状态下不加载本地
            if (!GlobalSettings.IsAppCheck)
            {
                AssetDataBases.UF_LoadAssetInfoFromPersistent();
            }
            UF_InitBundleAssets();
#else
            //编辑器下默认加载
            AssetDataBases.UF_LoadAssetInfoFromPersistent();
#endif
            yield return(null);
        }
コード例 #3
0
        //raw 的安装方式
        //拷贝全部Raw中文件到ResPersistent
        private int UF_threadInstallRaw(object e)
        {
            int retcode = 0;

            m_ProgressTotal  = Mathf.Max(1, GlobalSettings.ResFileCount);
            m_ProgressUpdate = 0;
            s_ProgresssZip   = 0;
            m_CurProgress    = 0;

            int bytekey = GlobalSettings.ResBKey;

            string runtimePath    = GlobalPath.ScriptPath;
            string bundlePath     = GlobalPath.BundlePath;
            string rawVersionFile = GlobalPath.StreamingAssetsPath + "/res_version.txt";
            string resVersionFile = GlobalPath.ResPersistentPath + "/res_version.txt";

            UF_SetUpgradeInfo(GlobalText.LAN_INSTALL_GAME);

            UF_logInfo(string.Format("App is Raw Asset package,Copy Raw to Persistent folder,File Count:{0}", m_ProgressTotal));

            //清除Res中的全部Runtime
            UF_deleteCacheFolder(new DirectoryInfo(runtimePath));

            //确保AssetDataBase中已经读入assetbase.asset资源文件映射信息


            //安装Asset 文件
            var listAssets = AssetDataBases.UF_GetAllAssets(AssetDataBases.AssetFileType.Runtimes | AssetDataBases.AssetFileType.Bundle);

            if (listAssets.Count > 0)
            {
                UF_logInfo(string.Format("Start to Install Raw Asset: {0} ", listAssets.Count));
                UF_installAssetFiles(listAssets, GlobalPath.ResPersistentPath, bytekey, ref m_CurProgress);
            }
            else
            {
                UF_logError("Asset to install if zero,Check AssetDataBase is already load asset table");
                return(-1101);
            }


            //拷贝version 文件
            UF_copyfile(rawVersionFile, resVersionFile);

            m_CurProgress = m_ProgressTotal;

            return(retcode);
        }
コード例 #4
0
ファイル: LuaFramework.cs プロジェクト: moto2002/FrameLock
        private void UF_InitLuaModules()
        {
            int tickstart = System.Environment.TickCount;
            //获取所有Lua代码资源文件
            var listRuntimes = AssetDataBases.UF_GetAllRuntimeInfos();

            //创建模块包文件
            UF_LoadLuaModulesPackages(listRuntimes);

            //加载所有模块全部lua文件
            UF_LoadLuaModulesFiles(listRuntimes);

            int tickend = System.Environment.TickCount;

            Debugger.UF_Log(string.Format("InitLuaModules Use Time: {0}", Math.Abs(tickend - tickstart)));

            m_IsInited = true;
        }
コード例 #5
0
ファイル: AssetSystem.cs プロジェクト: moto2002/FrameLock
        //审核模式下尝试加载替换资源文件
        //替换资源固有前缀为"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);
        }
コード例 #6
0
ファイル: AssetSystem.cs プロジェクト: moto2002/FrameLock
        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);
        }
コード例 #7
0
ファイル: DVBoardAsset.cs プロジェクト: moto2002/FrameLock
        public void UF_DrawInfo(Rect rect)
        {
            if (m_CurrentTag == TAG_INFO_ENTITY)
            {
                GUILayout.BeginHorizontal();
                var sb = StrBuilderCache.Acquire();
                sb.AppendLine(string.Format("== Active Count: {0} ==", CEntitySystem.UF_GetInstance().ActiveCount));
                sb.AppendLine();
                sb.AppendLine(CEntitySystem.UF_GetInstance().UF_GetActiveEntityInfo());
                GUI.color = Color.green;
                GUILayout.Box(sb.ToString());

                sb.Clear();
                sb.AppendLine(string.Format("== Pool Count: {0} ==", CEntitySystem.UF_GetInstance().PoolCount));
                sb.AppendLine();
                sb.AppendLine(CEntitySystem.UF_GetInstance().UF_GetPoolEntityInfo());
                GUI.color = Color.white;
                GUILayout.Box(sb.ToString());
                StrBuilderCache.Release(sb);
                GUILayout.EndHorizontal();
            }
            else if (m_CurrentTag == TAG_INFO_AB)
            {
                GUILayout.Label("Total Count: " + AssetSystem.UF_GetInstance().count);
                GUILayout.Box(AssetSystem.UF_GetInstance().ToString());
            }
            else if (m_CurrentTag == TAG_LOAD_TRACK)
            {
                if (Debugger.UF_GetInstance().MsgTrackers.ContainsKey(Debugger.TRACK_RES_LOAD))
                {
                    MsgTracker tracker = Debugger.UF_GetInstance().MsgTrackers[Debugger.TRACK_RES_LOAD];
                    GUILayout.Box(tracker.UF_ForeachToString(UF_TrackMsgForeach));
                }
            }
            else if (m_CurrentTag == TAG_UI)
            {
                var lastAlignment = GUI.skin.box.alignment;
                GUI.skin.box.alignment = TextAnchor.MiddleLeft;
                GUILayout.Box(UIManager.UF_GetInstance().ToString());
                GUI.skin.box.alignment = lastAlignment;
            }
            else if (m_CurrentTag == TAG_RefObject)
            {
                GUILayout.Box(RefObjectManager.UF_GetInstance().ToString());
            }
            else if (m_CurrentTag == TAG_AUDIO)
            {
                GUILayout.Box(AudioManager.UF_GetInstance().ToString());
            }
            else if (m_CurrentTag == TAG_SHADER)
            {
                GUILayout.Box(ShaderManager.UF_GetInstance().UF_GetShadersInfo());
            }
            else if (m_CurrentTag == TAG_ASSETDB)
            {
                int countBundle   = AssetDataBases.UF_GetAssetInfoCount(AssetDataBases.AssetFileType.Bundle);
                int countRebundle = AssetDataBases.UF_GetAssetInfoCount(AssetDataBases.AssetFileType.Rebundle);
                int countRuntimes = AssetDataBases.UF_GetAssetInfoCount(AssetDataBases.AssetFileType.Runtimes);
                int countNone     = AssetDataBases.UF_GetAssetInfoCount(AssetDataBases.AssetFileType.None);

                GUILayout.Box(string.Format("Bundle-> {0}", countBundle));
                GUILayout.Box(string.Format("Runtime-> {0}", countRuntimes));
                GUILayout.Box(string.Format("Rebundle-> {0}", countRebundle));
                GUILayout.Box(string.Format("None-> {0}", countNone));
            }
        }
コード例 #8
0
ファイル: AssetSystem.cs プロジェクト: moto2002/FrameLock
 public void UF_OnAwake()
 {
     //优先加载资源映射表
     AssetDataBases.UF_LoadAssetInfoFormAssetTable(GlobalPath.RawPath + "assettable.asset");
 }