我在两者之间切换的两个场景来自此代码使用的资产包。代码在编辑器中工作,但不在构建中。我错过了什么?无法从独立资产包加载场景
public IEnumerator LoadSceneBundle(string assetBundleSceneName, string orignialName) {
//url = "file://" + Application.dataPath + "/AssetBundles/" + assetBundleSceneName + ".unity3d";
Debug.Log(Application.dataPath);
//this code for build
newExtractedPath = Application.dataPath;
//this code for runtime
//newExtractedPath = Application.dataPath.Substring(0, Application.dataPath.Length - 7);
Debug.Log(newExtractedPath +" :: newExtractedPath");
//url = "file://" + Application.dataPath + "/AssetBundles/" + assetBundleSceneName + ".unity3d";
url = "file://" + newExtractedPath + "/AssetBundles/" + assetBundleSceneName + ".unity3d";
Debug.Log("scene load url : " + url);
using (WWW www = WWW.LoadFromCacheOrDownload(url,1)){
yield return www;
if (www.error != null) {
throw new Exception("WWW download had an error : " + url + " " + www.error);
//Debug.Log("");
}
AssetBundle ab = www.assetBundle;
Debug.Log(www.assetBundle.mainAsset);
ab.LoadAll();
Application.LoadLevel(originalName);
ab.Unload(false);
}
}
部署后,我做了一个AssetsBundle文件夹,并放置我的assetbundle场景文件,但它不起作用。一切都是徒劳的。
因此,标准的方式是将assetbundle放入streamingAsset文件夹中,并且该文件夹将在我们独立构建时自动部署?对? –
是的。在_Assets_文件夹('Assets/StreamingAssets /') – Roberto
+中创建文件夹感谢这个有价值的信息,但这不是问题! –