Beispiel #1
0
 //构建资源包
 void BuildResource(ResPackInfo ResInfo, string ifsBuildDir, BuildTarget target)
 {
     if (ResInfo.GetPackType() == (byte)ResPackType.ResPackTypeBundle)
     {
         BuildBundleResource(ResInfo as BundlePackInfo, ifsBuildDir, target);
     }
     else if (ResInfo.GetPackType() == (byte)ResPackType.ResPackTypeBinary)
     {
         BuildNormalResource(ResInfo as BinaryPackInfo, ifsBuildDir);
     }
 }
Beispiel #2
0
        //根据manifest检查一遍依赖关系
        private void CheckAndClearManifestFiles(BuildTarget target, bool isClear = false)
        {
            string ifsBuildDir = JW.Res.FileUtil.CombinePaths(
                _ifsBuildPath,
                GetPlatformStr(target));
            //
            string      mainAssetBundlePath = JW.Res.FileUtil.CombinePaths(ifsBuildDir, GetPlatformStr(target));
            AssetBundle mainAssetBundle     = AssetBundle.LoadFromFile(mainAssetBundlePath);

            if (mainAssetBundle == null)
            {
                Terminate("Get RootAssetBundle Failed");
                return;
            }

            AssetBundleManifest mainAssetManifest = (AssetBundleManifest)mainAssetBundle.LoadAsset("AssetBundleManifest");

            if (mainAssetManifest == null)
            {
                Terminate("Get RootAssetBundle Manifest Failed!");
                return;
            }
            //
            string[] allAbs = mainAssetManifest.GetAllAssetBundles();
            foreach (string ab in allAbs)
            {
                JW.Common.Log.LogD("Exist AssetBundle:" + ab);
            }
            //
            for (int i = 0; i < _packConfig.PackInfoAll.Count; i++)
            {
                ResPackInfo info = _packConfig.PackInfoAll[i];
                if (info.GetPackType() == (byte)ResPackType.ResPackTypeBundle)
                {
                    BundlePackInfo binfo = info as BundlePackInfo;
                    //查找依賴
                    string[] des = mainAssetManifest.GetAllDependencies(info.Path);
                    if (des != null && des.Length > 0)
                    {
                        binfo.DependencyNames = string.Join(",", des);
                        JW.Common.Log.LogD("Add Dependency:" + binfo.DependencyNames + "-2->" + info.Path);
                    }
                }
            }
            //
            mainAssetBundle.Unload(true);
            mainAssetManifest = null;
            //
            if (isClear)
            {
                string[] files = Directory.GetFiles(ifsBuildDir, "*.manifest", SearchOption.AllDirectories);
                for (int i = 0; i < files.Length; i++)
                {
                    JW.Res.FileUtil.DeleteFile(files[i].Replace('\\', '/'));
                }
                //删除 Win Android IOS
                JW.Res.FileUtil.DeleteFile(mainAssetBundlePath);
            }
        }
Beispiel #3
0
        /// 只打包二进制
        public void BuildBinaryPacker(BuildTarget target)
        {
            //当前配置的打包
            if (_packConfig == null)
            {
                Terminate("You must call InitResourcePacker() before BuildResourcePacker()!");
                return;
            }
            JW.Common.Log.LogD("-->开始打包二进制: " + GetPlatformStr(target));
            //IFS输出目录
            string ifsBuildDir = JW.Res.FileUtil.CombinePaths(
                _ifsBuildPath,
                GetPlatformStr(target));

            if (!JW.Res.FileUtil.IsDirectoryExist(ifsBuildDir))
            {
                JW.Res.FileUtil.CreateDirectory(ifsBuildDir);
            }
            //目标target
            ResPackHelper.BuildTarget = target;
            try
            {
                for (int i = 0; i < _packConfig.PackInfoAll.Count; i++)
                {
                    ResPackInfo info = _packConfig.PackInfoAll[i];
                    if (info.GetPackType() == (byte)ResPackType.ResPackTypeBinary)
                    {
                        BuildResource(info, ifsBuildDir, target);
                    }
                }
            }
            catch (Exception e)
            {
                Terminate(e.Message);
            }
        }