public IEnumerator LoadedAsset(AssetBundleManager assetBundleManager, string assetBundleName, string assetName) { assetBundleName = assetBundleManager.RemapVariantName(assetBundleName); bundleLoaded = assetBundleManager.LoadAssetBundleAsync(assetBundleName); yield return(bundleLoaded); AssetBundleRequest request = bundleLoaded.assetBundle.LoadAssetAsync <MultiSceneSetup>(assetName); yield return(request); MultiSceneSetup multiSceneSetup = request.asset as MultiSceneSetup; if (multiSceneSetup != null) { maxLoaded = multiSceneSetup.scenePaths.Length; for (int i = 0; i < multiSceneSetup.scenePaths.Length; i++) { indexLoaded = i; string bundleName; if (!assetBundleManager.GetBundleName(multiSceneSetup.scenePaths[i], out bundleName)) { continue; } yield return(LoadedAsset(assetBundleManager, bundleName, Path.GetFileNameWithoutExtension(multiSceneSetup.scenePaths[i]))); } } indexLoaded = maxLoaded; }
public bool LoadMultiScene(string assetName) { MultiSceneSetup multiSceneSetup = LoadAsset <MultiSceneSetup>(assetName); if (multiSceneSetup == null) { return(false); } for (int i = 0; i < multiSceneSetup.scenePaths.Length; i++) { LoadScene(multiSceneSetup.scenePaths[i], i == 0 ? LoadSceneMode.Single : LoadSceneMode.Additive); } if (multiSceneSetup.indexActiveScene >= 0 && multiSceneSetup.indexActiveScene < multiSceneSetup.scenePaths.Length) { string sceneName = "Assets/" + multiSceneSetup.scenePaths[multiSceneSetup.indexActiveScene]; for (int i = 0; i < SceneManager.sceneCount; i++) { Scene scene = SceneManager.GetSceneAt(i); if (scene.path == sceneName) { SceneManager.SetActiveScene(scene); break; } } } return(true); }