文章目录
前言
要挂VPN
Xlua官方下载地址:https://github.com/Tencent/xLua
提示:以下是本篇文章正文内容,下面案例可供参考
一、Bundle处理
1.查找BuildResources下的资源文件
2.使用Unity提供的BuidPipeline进行构建
3.注意:meta不需要打入bundle包
一、Bundle Build构建
1.打包模式
1.按文件夹打包
优势:Bundle数量少,小包模式:首次下载块
劣势:后期更新的时候,更新补丁大
2.按文件打包优势:更新补丁小
劣势:小包模式:首次下载稍慢
1.文件夹打包是以最后一个文件夹里的所有东西一起打包
2.文件打包是指定文件打包
下面演示的是按文件打包
2.代码演示
(查找BuildResources下的资源文件)
(使用Unity提供的BuidPipeline进行构建)
(遍历meta文件)
代码如下(示例):
BuildTool
static void Build(BuildTarget target)
{
List<AssetBundleBuild> assetBundleBuilds = new List<AssetBundleBuild>();
//文件信息列表
List<string> bundleInfos = new List<string>();
//获取全部文件路径,第一个参数(AsseetsPath + "/BuildResources/")然后是搜索的匹配值数参(“*”),搜索选项,全部的文件夹(Asstes文件下的BuildResources文件)
string[] files = Directory.GetFiles(PathUtil.BuildResourcesPath, "*", SearchOption.AllDirectories);
//排除meta文件
for (int i = 0; i < files.Length; i++)
{
//如果Asstes文件下的BuildResources文件存在meta文件就退出
if (files[i].EndsWith(".meta"))
continue;
AssetBundleBuild assetBundle = new AssetBundleBuild();
//所有Asstes文件下的BuildResources文件的名字
string fileName = PathUtil.GetStandardPath(files[i]);
Debug.Log("file:" + fileName);
string assetName = PathUtil.GettUnityPath(fileName);
assetBundle.assetNames =new string[] { assetName };
//Replace 替换字符串 ToLower 转换成小写
string bundleName = fileName.Replace(PathUtil.BuildResourcesPath, "").ToLower();
assetBundle.assetBundleName = bundleName + ".ab";
assetBundleBuilds.Add(assetBundle);
//添加文件和依赖信息
List<string> dependenceInfo = GetDependence(assetName);
string bundleInfo = assetName + "|" + bundleName;
if (dependenceInfo.Count > 0)
bundleInfo = bundleInfo + "|" + string.Join("|", dependenceInfo);
bundleInfos.Add(bundleInfo);
}
//文件是否存在 存在就删除 在创建
if (Directory.Exists(PathUtil.BundleOutPath))
Directory.Delete(PathUtil.BundleOutPath, true);
Directory.CreateDirectory(PathUtil.BundleOutPath);
//第一个参数是路径、StreamingAssets文件夹的路径,第二个参数一个AssetBundleBuild的列表(数据),第三个参数是压缩格式,第四个参数是目标平台
BuildPipeline.BuildAssetBundles(PathUtil.BundleOutPath, assetBundleBuilds.ToArray(), BuildAssetBundleOptions.None, target);
//Directory.GetDirectories (找到全部文件夹),Directory.GetFiles(找到全部文件)
File.WriteAllLines(PathUtil.BundleOutPath + "/" + AppConst.FileListName, bundleInfos); //写成文件
//刷新
AssetDatabase.Refresh();
}
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。