Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/GPX_Example.cs
2026-03-04 09:37:33 +08:00

54 lines
2.0 KiB
C#

using System.Collections;
using System.IO;
using GISTech.GISTerrainLoader;
using UnityEngine;
public class GPX_Example : MonoBehaviour
{
private string TerrainFilePath = Application.streamingAssetsPath + "/GIS Terrains/GPXTerrain/GPXTerrain.tif";
private RuntimeTerrainGenerator RuntimeGenerator;
private GISTerrainLoaderPrefs Prefs;
private GISTerrainLoaderRuntimePrefs RuntimePrefs;
private void Start()
{
RuntimePrefs = GISTerrainLoaderMonoSingleton<GISTerrainLoaderRuntimePrefs>.Get;
Prefs = RuntimePrefs.Prefs;
RuntimeGenerator = GISTerrainLoaderMonoSingleton<RuntimeTerrainGenerator>.Get;
StartCoroutine(GenerateTerrain(TerrainFilePath));
}
private void InitializingRuntimePrefs(string TerrainPath)
{
RuntimeGenerator.enabled = true;
Prefs.TerrainFilePath = TerrainPath;
Prefs.RemovePrvTerrain = OptionEnabDisab.Enable;
Prefs.TerrainElevation = TerrainElevation.RealWorldElevation;
Prefs.terrainDimensionMode = TerrainDimensionsMode.AutoDetection;
Prefs.heightmapResolution = 513;
Prefs.textureMode = TextureMode.WithTexture;
Prefs.vectorType = VectorType.GPX;
Prefs.EnableRoadGeneration = OptionEnabDisab.Enable;
GISTerrainLoaderSO_Road pathPrefab = (GISTerrainLoaderSO_Road)Resources.Load("Prefabs/Environment/Roads/GPX_GeoLine_Model", typeof(GISTerrainLoaderSO_Road));
Prefs.PathPrefab = pathPrefab;
Prefs.EnableGeoPointGeneration = OptionEnabDisab.Enable;
GameObject geoPointPrefab = (GameObject)Resources.Load("Prefabs/Environment/GeoPoints/PointPrefabs/GeoLocation", typeof(GameObject));
Prefs.GeoPointPrefab = geoPointPrefab;
}
private IEnumerator GenerateTerrain(string TerrainPath)
{
yield return new WaitForSeconds(2f);
if ((Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) && (string.IsNullOrEmpty(TerrainPath) || !File.Exists(TerrainPath)))
{
Debug.LogError("Terrain file null or not supported.. Try againe");
yield break;
}
InitializingRuntimePrefs(TerrainPath);
StartCoroutine(RuntimeGenerator.StartGenerating(Prefs));
}
}