前端之家收集整理的这篇文章主要介绍了
Unity5.3.5加载AssetBundle包及依赖,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
IEnumerator loadScene(string sceneName)
{
string mainPath = "file://" + Application.streamingAssetsPath + "/AssetBundle/" + "AssetBundle";
WWW www1 = new WWW (mainPath);
yield return www1;
if(www1.error == null)
{
AssetBundle mainAB = www1.assetBundle;
AssetBundleManifest abm = (AssetBundleManifest)mainAB.LoadAsset("AssetBundleManifest");
mainAB.Unload (false);
if (abm == null) {
Debug.Log ("abm is null");
yield return null;
} else {
string[] depNames = abm.GetAllDependencies ("a.assetbundle");
Debug.Log ("depNames length = " + depNames.Length.ToString());
}
}
string fileFullPath = "file://" + Application.streamingAssetsPath + "/AssetBundle/" + sceneName+"."+AB_END;
WWW www = new WWW (fileFullPath);
yield return www;
if (www.error == null)
{
AssetBundle abScene=www.assetBundle;
SceneManager.LoadScene (sceneName);
}
else
{
Debug.LogError ("fileFullPath:"+fileFullPath+" error:" + www.error);
}
www.Dispose ();
www = null;
}