AssetBundle中约有5个模型的名称为“厨房”,约3个模型的名称为“家具”。然后,使用以下代码将它们创建到本地路径中:
[MenuItem("Assets/Build Home Assets")]
static void BuildKitchenAssets()
{
BuildPipeline.BuildAssetBundles("/Users/ar/Desktop/HomeBundles",BuildAssetBundleOptions.ChunkBasedCompression,BuildTarget.iOS);
}
现在,我希望将文件下载到手持设备文件夹(IOS / Android)中。这是我要实现的:
我想将它们动态添加到列表(汉堡模型)。有一些疑问。我想要一种有效的方法来做到这一点。是否应该将所有assetbundle文件从文件夹结构下载到设备路径?如果已下载,则不要再次下载该捆绑软件。同时,如果我向“厨房”资产捆绑包添加了新模型,则必须检查并更新捆绑包。
void Update()
{
}
IEnumerator GetBundles()
{
using(UnityWebRequest uwr=UnityWebRequestAssetBundle.GetAssetBundle(url,XXXXXXXX,0))
{
yield return uwr.SendWebRequest();
if (uwr.error != null)
{
throw new Exception("WWW download error: "+uwr.error);
}
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);
if(AssetName==" ")
{
Instantiate(bundle.mainAsset);
}
else
{
//GameObject go=bundle.LoadAsset<GameObject>(AssetName);
GameObject go = bundle.LoadAsset(AssetName) as GameObject;
Instantiate(go);
}
}
//How to save them into 'device' folder. For App purpose so need to connect
//to the internet at the start and download.Then no need to download again.
// Also check if there is any change in assetbundle.
}
使用新的“可寻址”功能。它将自动处理下载到适当的位置。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句