1234567891011121314151617181920212223242526272829303132333435363738 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TerrainLoader : MonoBehaviour
- {
- void Start()
- {
- StartCoroutine(LoadTerrain());
- }
-
- IEnumerator LoadTerrain()
- {
- WaitForEndOfFrame wait = new WaitForEndOfFrame();
- WWW www = WWW.LoadFromCacheOrDownload($"{Application.streamingAssetsPath}/terrainv2",0);
- yield return www;
- if (www.isDone)
- {
- var tempAb = www.assetBundle;
- GameObject terrain_di = tempAb.LoadAsset<GameObject>("Di");
- Instantiate(terrain_di, this.transform);
- for (int i = 0; i < 8; i++)
- {
- for (int j = 2; j < 8; j++)
- {
- GameObject terrain_tempQuad = tempAb.LoadAsset<GameObject>($"Mount_Rainier_x{i}_y{j}");
- Instantiate(terrain_tempQuad, this.transform);
- yield return wait;
- }
- }
- }
- else
- {
- Debug.LogError($"TerrainV2下载失败:{www.error}");
- }
- www.Dispose();
- }
- }
|