问题
- 当您尝试加载包含场景的AssetBundle时,会发生崩溃。出现错误码:"InvalidOperationException: This method cannot be used on a streamed scene AssetBundle.at UnityEngine.AssetBundle.LoadAllAssets (System.Type type) [0x00000] in <filename unknown>:0"。
原因
在Unity 5.3.4p5中,如果AssetBundle是场景包,则可以调用LoadAll Assets加载场景。 如果您升级到5.3.5p5,它却会崩溃或显示错误。
解决方案
当您从AssetBundle中加载场景时,不必要调用LoadAllAssets。
您可以通过使用AssetBundle.isStreamedSceneAssetBundle 检查一个包是否为流式场景
www = new WWW( urlServer + bundleName);
yield return www;
AssetBundle bundle = www.assetBundle;
if ( bundle.isStreamedSceneAssetBundle)
{
SceneManager.LoadSceneAsync( sceneName , LoadSceneMode.Additive );
}
更多信息
本文适用于Unity 5.3.5p5版本。
https://docs.unity3d.com/Manual/AssetBundlesIntro.html
https://unity3d.com/learn/tutorials/topics/best-practices/guide-assetbundles-and-resources
评论
0 条评论
请登录写评论。