Example #1
0
    // Token: 0x06005BD3 RID: 23507 RVA: 0x002009DC File Offset: 0x001FEDDC
    public IEnumerator InstantiateDownloadedScene(AssetBundleDownload download, float timeLimit, Action onSuccess, Action <string> onError)
    {
        if (download == null)
        {
            Debug.LogError("Download was null");
            if (onError != null)
            {
                onError("Download was null");
            }
            yield break;
        }
        AssetBundle ab = download.assetBundle;

        if (ab == null)
        {
            Debug.LogError("Asset bundle did not load");
            if (onError != null)
            {
                onError("Asset bundle did not load");
            }
            yield break;
        }
        VRCAudioManager.EnableAllAudio(false);
        string[] sceneFiles = ab.GetAllScenePaths();
        if (sceneFiles.Length != 1)
        {
            Debug.LogWarning("VRCW file has bad scene count - " + download.assetUrl);
        }
        string sceneName = Path.GetFileNameWithoutExtension(sceneFiles[0]);

        Debug.Log("Loading scene: " + sceneName);
        AssetBundleDownloadManager.RegisterManuallyLoadedAssetBundle(download.assetUrl, ab, ab);
        bool loadLevelSuccess = false;

        yield return(AssetManagement.LoadLevelAsync(sceneName, LoadSceneMode.Single, timeLimit, delegate
        {
            loadLevelSuccess = true;
        }));

        if (!loadLevelSuccess)
        {
            Debug.LogError("Failed to load scene " + sceneName + ", LoadLevelAsync failed");
            if (onError != null)
            {
                onError("Failed to load scene " + sceneName + ", LoadLevelAsync failed");
            }
            yield break;
        }
        Scene scene = SceneManager.GetSceneByName(sceneName);

        if (!scene.isLoaded)
        {
            Debug.LogError("Failed to load scene " + sceneName);
            if (onError != null)
            {
                onError("Failed to load scene " + sceneName);
            }
            yield break;
        }
        if (!this.ProcessSceneObjectsImmediate())
        {
            Debug.LogError("Error processing scene objects post load");
            if (onError != null)
            {
                onError("Error processing scene objects post load, scene " + sceneName);
            }
            yield break;
        }
        yield return(null);

        yield return(null);

        SceneManager.SetActiveScene(scene);
        yield return(null);

        onSuccess();
        yield break;
    }