Question by
tony040209 · Apr 17, 2017 at 03:10 PM ·
c#androidassetbundle
Asseatbundle Local Download for android path problem
"jar:file://" + Application.dataPath + "!/assets/"
I want local download asseatbundle with android
but is not working
help!
========================================
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class BunderLoader : MonoBehaviour {
public static readonly string bundleUrl =
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
"file://C://Users/tony/Desktop/unity 5.1.1/正妹防衛隊/Assetbundles/balloon_01.bundle";
#elif UNITY_ANDROID
"jar:file://" + Application.dataPath + "!/assets/Assetbundles/balloon_01.bundle";
#else
string.Empty;
#endif
/*IEnumerator start(){
WWW www = new WWW (bundleUrl);
yield return www;
AssetBundle bundle = www.assetBundle;
GameObject balloon_01 = Instantiate (bundle.LoadAsset("balloon_01")) as GameObject;
}*/
IEnumerator Start()
{
// 从URL中下载文件,不会存储在缓存中。
using (WWW www = new WWW(bundleUrl))
{
yield return www;
if (www.error != null)
throw new Exception("WWW download had an error:" + www.error);
AssetBundle bundle = www.assetBundle;
GameObject Balloon_01 = Instantiate(bundle.LoadAsset("balloon_01")) as GameObject;
// 卸载加载完之后的AssetBundle,节省内存。
bundle.Unload(false);
}//由于使用using语法,www.Dispose将在加载完成后调用,释放内存
}
}
Comment