private IEnumerator LoadTerrain()
    {
        Instantiate(TerrainLoadingCanvasPrefab).TerrainLoader = this;

        yield return(null);

        //Load Navmesh's asset bundle
        if (!string.IsNullOrEmpty(NavMeshBundlePath))
        {
            AssetBundleCreateRequest navMeshBundleRequest = AssetBundle.LoadFromFileAsync(NavMeshBundlePath);

            AssetBundle loadedNavMeshBundle = navMeshBundleRequest.assetBundle;

            var navMesh = loadedNavMeshBundle.LoadAssetAsync("navmesh");
            yield return(navMesh);
        }
        //Load the terrain's assetbundle
        var bundleLoadRequest = AssetBundle.LoadFromFileAsync(AssetBundlePath);

        yield return(bundleLoadRequest);

        LoadState = TerrainLoadState.Loading;
        var loadedAssetBundle = bundleLoadRequest.assetBundle;
        var terrainSceneName  = Path.GetFileNameWithoutExtension(loadedAssetBundle.GetAllScenePaths()[0]);

        assetLoadRequest = SceneManager.LoadSceneAsync(loadedAssetBundle.GetAllScenePaths()[0], LoadSceneMode.Additive);
        yield return(assetLoadRequest);

        loadedAssetBundle.Unload(false);

        LoadedScene = SceneManager.GetSceneByName(terrainSceneName);

        LoadState = TerrainLoadState.TerrainOnly;

        if (ImprovedTerrain)
        {
            StartCoroutine(LoadImprovedTerrainCoroutine());
        }

        Invoke_TerrainOnlyLoaded();

        PutCopyFull       = LoadedScene.GetRootGameObjects()[0].GetComponentInChildren <PutCopy>();
        PutCopyFull.Done += OptimizeTerrain;

        if (Application.isEditor)
        {
            LoadState = TerrainLoadState.BeforeCombine;

            Invoke_TerrainFullyLoadedBeforeCombine();

            LoadState = TerrainLoadState.Fully;

            Invoke_TerrainFullyLoaded();
        }
    }
Example #2
0
 public ExternalReferencesBank(PutCopy putCopyComponent)
 {
     bank = new Dictionary <string, ExternalReference>();
     this.putCopyComponent = putCopyComponent;
 }