微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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;
	}

原文地址:https://www.jb51.cc/javaschema/283709.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐