Unity5在Asset bundle 打包管理上采用了全新的方式,不需要再对每个文件进行MD5比对,unity已经帮我们做好了,对需要打包的资源AssetBundle属性就行了,同事Unity还提供了一个打包管理工具 Asset Bundle Manager。
官方文档对这个工具的说明及使用方式,地址
官方的工具项目工程地址
说下使用方式,工具提供了一键打包,本地加载模拟,网络加载模拟。
打包很简单,设定好属性,直接打包就行。本地加载模拟,右键选择Simulation mode即可切换到此模式进行测试。
还有一个是本地网络加载模拟,在本地搭建一个资源服务器,客户端连接这个服务器来进行动态的加载资源,但是实际测试中发现会报错,经过修改,终于好了。
首先需要在BuildScript.cs里修改变量为
public static string overloadedDevelopmentServerURL = "http://192.168.1.101:7888/";
- 1
具体的IP要根据自己的电脑来设定
然后修改LaunchAssetBundleServer.cs文件,主要是Run()函数,修改后的Run函数如下
static void Run () { string pathToAssetServer = Path.Combine(Application.dataPath, "AssetBundleManager/Editor/AssetBundleServer.exe"); string pathToApp = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf('/')); pathToAssetServer = pathToAssetServer.Replace("/", "\\"); pathToApp = pathToApp.Replace("/", "\\"); KillRunningAssetBundleServer(); BuildScript.WriteServerURL(); string args = Path.Combine(pathToApp, "AssetBundles"); ProcessStartInfo startInfo = new ProcessStartInfo(pathToAssetServer); ; startInfo.Arguments = args; Process launchProcess = Process.Start(startInfo); if (launchProcess == null || launchProcess.HasExited == true || launchProcess.Id == 0) { //Unable to start process UnityEngine.Debug.LogError ("Unable Start AssetBundleServer process"); } else { //We seem to have launched, let's save the PID instance.m_ServerPID = launchProcess.Id; } }
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
如此便可正常使用了。
项目工程里有资源场景的加载示例,有兴趣的可以自行研究。