forked from mapbox/mapbox-unity-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTerrainLayerModuleScript.cs
More file actions
54 lines (47 loc) · 1.64 KB
/
TerrainLayerModuleScript.cs
File metadata and controls
54 lines (47 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections;
using System.Collections.Generic;
using Mapbox.BaseModule;
using Mapbox.BaseModule.Data.Interfaces;
using Mapbox.BaseModule.Data.Tiles;
using Mapbox.BaseModule.Map;
using Mapbox.BaseModule.Unity;
using Mapbox.BaseModule.Utilities;
using Mapbox.ImageModule;
using Mapbox.ImageModule.Terrain;
using Mapbox.ImageModule.Terrain.Settings;
using Mapbox.ImageModule.Terrain.TerrainStrategies;
using UnityEngine;
namespace Mapbox.Example.Scripts.ModuleBehaviours
{
public class TerrainLayerModuleScript : ModuleConstructorScript
{
public TerrainLayerModuleSettings Settings = new TerrainLayerModuleSettings()
{
RejectTilesOutsideZoom = new Vector2(10, 25),
DataSettings = new ImageSourceSettings()
{
ClampDataLevelToMax = 14
}
};
public override ILayerModule ModuleImplementation { get; protected set; }
//do not delete
//having a start method forces unity to have an enable/disable script checkbox in the inspector
//and even though we aren't using Start method, we are using that checkbox to enable/disable the module
private void Start()
{
}
public override ILayerModule ConstructModule(MapService service, IMapInformation mapInformation, UnityContext unityContext)
{
var elevationTileset = MapboxDefaultElevation.GetParameters(Settings.SourceType);
Settings.DataSettings.TilesetId = elevationTileset.Id;
var module =
new TerrainLayerModule(
service.GetTerrainRasterSource(Settings.DataSettings),
Settings,
new ElevatedTerrainStrategy());
mapInformation.QueryElevation = module.QueryElevation;
ModuleImplementation = module;
return ModuleImplementation;
}
}
}