我在兩者之間切換的兩個場景來自此代碼使用的資產包。代碼在編輯器中工作,但不在構建中。我錯過了什麼?無法從獨立資產包加載場景
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
+中創建文件夾感謝這個有價值的信息,但這不是問題! –