コード例 #1
0
ファイル: LuaMgr.cs プロジェクト: ElmerNing/UnityFramework
        public void StartUp()
        {
            LuaConst.luaResDir = ResHelper.GetLuaFolder();


            LuaState lua = new LuaState();

            //重新创建lua读取
            new LuaFileUtils();

            //设置lua搜索路径

#if UNITY_EDITOR
            //编辑器模式下永远使用 Assets下的lua
            lua.AddSearchPath(LuaConst.luaDir);
            lua.AddSearchPath(LuaConst.toluaDir);
#else
            //非编辑器模式下永远使用Res下的Lua
            lua.AddSearchPath(ResHelper.GetLuaFolder());
#endif



            //启动lua
            lua.Start();
            LuaBinder.Bind(lua);
            DelegateFactory.Init();
            lua.DoFile("Main.lua");


            this.gameObject.AddComponent <LuaLooper>().luaState = lua;
        }
コード例 #2
0
        public void StartUp()
        {
            LuaConst.luaResDir = ResHelper.GetLuaFolder();


            LuaState lua = new LuaState();

            //重新创建lua读取
            new LuaFileUtils();

            //设置lua搜索路径

#if UNITY_EDITOR
            //编辑器模式下永远使用 Assets下的lua
            lua.AddSearchPath(LuaConst.luaDir);
            lua.AddSearchPath(LuaConst.toluaDir);
#else
            //非编辑器模式下永远使用Res下的Lua
            lua.AddSearchPath(ResHelper.GetLuaFolder());
#endif



            lua.OpenLibs(LuaDLL.luaopen_pb);
            lua.OpenLibs(LuaDLL.luaopen_struct);
            lua.OpenLibs(LuaDLL.luaopen_lpeg);
            //lua.OpenLibs(luaopen_protobuf_c);
#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
            luaState.OpenLibs(LuaDLL.luaopen_bit);
#endif



            if (LuaConst.openLuaSocket)
            {
                lua.BeginPreLoad();
                lua.RegFunction("socket.core", LuaOpen_Socket_Core);
                lua.RegFunction("mime.core", LuaOpen_Mime_Core);
                lua.EndPreLoad();
            }

            lua.LuaSetTop(0);

            //启动lua
            lua.Start();
            LuaBinder.Bind(lua);
            DelegateFactory.Init();
            lua.DoFile("Main.lua");


            this.gameObject.AddComponent <LuaLooper>().luaState = lua;
        }
コード例 #3
0
ファイル: ResBuilder.cs プロジェクト: hbszqf/UnityFrameWork
        /// <summary>
        /// BuildRes
        /// </summary>
        /// <param name="target"></param>
        public void BuildRes(BuildTarget target)
        {
            //切换平台
            UnityEditor.EditorUserBuildSettings.SwitchActiveBuildTarget(BuildPipeline.GetBuildTargetGroup(target), target);

            //编译AB
            {
                string abFolder = ResHelper.GetABFolder(target);
                Directory.CreateDirectory(abFolder);

                //编译AB
                var manifest = BuildPipeline.BuildAssetBundles(abFolder, assetBundleBuildList.ToArray(), BuildAssetBundleOptions.ChunkBasedCompression, target);

                //所有的
                string[] abNameArray = manifest.GetAllAssetBundles();

                //删除无用的AB
                HashSet <string> abNameSet = new HashSet <string>(abNameArray);
                string[]         files     = Directory.GetFiles(abFolder);
                foreach (var item in files)
                {
                    string fileName = Path.GetFileName(item);
                    fileName = fileName.Replace(".manifest", "");
                    if (!abNameSet.Contains(fileName) && fileName != "AB")
                    {
                        Log.Print("删除AB:" + item);
                        File.Delete(item);
                    }
                }
            }

            //复制不打成AB的文件
            FileUtil.CopyDirectory("*", ResHelper.GetAssetsResWichIsNotABFolder(), ResHelper.GetResFolder(target), false);

            //复制
            foreach (var copyFolder in this.config.copyFolderList)
            {
                string org     = ResHelper.GetAssetsResFolder() + copyFolder.folder;
                string dst     = ResHelper.GetResFolder(target) + copyFolder.folder;
                string pattern = "*";
                if (copyFolder.pattern != null)
                {
                    pattern = copyFolder.pattern;
                }
                FileUtil.CopyDirectory(pattern, org, dst);
            }

            //复制Lua
            {
                string dst = ResHelper.GetLuaFolder();
                if (Directory.Exists(dst))
                {
                    Directory.Delete(dst, true);
                }
                FileUtil.CopyDirectory("*.lua", LuaConst.luaDir, dst, false);
                FileUtil.CopyDirectory("*.lua", LuaConst.toluaDir, dst, false);
            }


            //生成sbf
            CreateSBFAdnSave(ResHelper.GetResFolder(target));
        }