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;
}
首先加载全部资源的AssetBundle,然后加载依赖,再加载场景文件