作者lovecold (小猪头)
看板GameDesign
标题[程式] 关於Unity的AssetBundle
时间Thu Jun 13 09:41:23 2013
各位前辈好,小弟弟我目前正在学着使用Unity的AssetBundle来做android的obb档
但碰到一个小问题,希望各位前辈能指点指点....
我照着Unity提供的GooglePlayDownloader的说明来产生obb档
1) Create one or many AssetBundles with the application data
(enough to get the .apk below the 50MB limit).
2) Concatenate the generated AssetBundles into a single .obb
by ZIP'ing them, using STORE (not DEFLATE).
$> zip -0 main.obb assetbundles
3) Continue to use WWW.LoadFromCacheOrDownload()
as with regular asset bundle loading, but use the path
to the .obb instead, like this:
WWW.LoadFromCacheOrDownload("jar:file://" +
obbPath +
"!/" + originalAssetBundleName);
在第二步骤时,我把三个assetbundle压缩成一个main.obb档,
这三个assetbundle分别是
RedCube.assetbundles,
GreenCube.assetBundles,
BuleCube.assetBundles
但在第三步骤时出现问题,
当我在Editor测试时,使用
string obbPath = "jar:file://"+
Application.dataPath +
"/../_AssetBunldes/main.obb!/RedCube.assetBundles";
WWW bundle = WWW.LoadFromCacheOrDownload(obbPath, 0);
Debug.Log(bundle.assetBundle);
会出现下方的错误
You are trying to load data from a www stream
which had the following error when downloading.
Resolving host timed out: jar:file:
UnityEngine.WWW:get_assetBundle()
<loadBundle>c__Iterator0:MoveNext() (at Assets/DownloadObbExample.cs:62)
当我在机器上测试时,我把路径改成,
string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
string obbPath = "jar:file://"+ mainPath + "!/RedCube.assetBundles";
WWW bundle = WWW.LoadFromCacheOrDownload(obbPath, 0);
Debug.Log(bundle.assetBundle);
这样不会有错误讯息,但也不会秀出log
想请教一下,是我那里做错了吗??
谢谢各位的帮忙!!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 125.230.84.190
※ 编辑: lovecold 来自: 125.230.84.190 (06/13 09:45)
1F:推 holymars:Editor认不得jar:这种uri 有错是正常的 06/13 21:34
原来如此,感谢提醒
2F:→ holymars:在机器上要是没跑到Debug那行一定是有错误讯息你漏了才对 06/13 21:35
3F:推 holymars:另外WWW class你要检查isDone 才能拿东西吧 就算在local 06/13 21:37
4F:→ holymars:端的档案也一样.. 06/13 21:37
原来是要加,因为之前测试时有加一样没有印出LOG,以为是卡死在回圈内
所以把isDone拿掉了..感谢你的帮忙!!!^^
※ 编辑: lovecold 来自: 114.38.96.63 (06/13 23:45)