【发布时间】:2018-10-11 14:15:27
【问题描述】:
我为我的项目创建了一些资产包场景。现在我正在下载资产包并能够加载场景。这里的问题是,当我运行一个场景并退出该场景并尝试再次重新加载同一场景时,它会给出类似
的错误“无法加载 Assetbundle mywebsite.com/bundles/assetbundle.unity3d,因为已经加载了具有相同文件的另一个 AssetBundle。”
我无法第二次打开场景。谁能告诉我问题并帮助我解决?!提前致谢。
我在这里添加代码:
IEnumerator sceneLoad()
{
WWW www = WWW.LoadFromCacheOrDownload(myurl,version);
while (!www.isDone)
{
msg.text = "Downloading...";
float progress = Mathf.Clamp01 (www.progress / .9f);
progressslide.value = progress;
float val = progress * 100f;
double value = System.Math.Round (val, 2);
progresstext.text = value + "%";
Debug.Log ("Progress " + progresstext.text);
yield return null;
}
bundle = www.assetBundle;
msg.text = "Opening Scene...";
progressslide.gameObject.SetActive (false);
progresstext.gameObject.SetActive (false);
string[] scenepath = bundle.GetAllScenePaths ();
Debug.Log (scenepath [0]);
var async = SceneManager.LoadSceneAsync(System.IO.Path.GetFileNameWithoutExtension (scenepath [0]));
yield return null;
bundle.Unload (false);
}
上面的代码在我的电脑上的统一引擎上完美运行,但是当我构建 apk 并在手机上运行时,进度条不工作,但包正在下载并且场景正在打开。后来当我退出场景时,来到我的应用程序主页并再次打开相同的场景,它显示错误为
“无法加载 Assetbundle mywebsite.com/bundles/assetbundle.unity3d,因为已经加载了具有相同文件的另一个 AssetBundle。”
我在下载的场景中使用 Vuforia。
【问题讨论】:
-
下次请自行格式化代码
标签: unity3d vuforia assetbundle