Viewport API
advanced scriptingWorld Map Strategy Kit · Scripting Support (C#)
WMSK (namespace WorldMapStrategyKit)
Viewport API
Methods and properties for the viewport feature (3D terrain mode).
Properties
GameObject renderViewport { get; set; }The Viewport GameObject for 3D terrain mode. Assign a terrain or mesh to enable viewport rendering.
bool renderViewportIsEnabled { get; }Returns true if the viewport is currently active.
bool renderViewportIsTerrain { get; }Returns true if the viewport is using Unity Terrain mode.
Rect renderViewportRect { get; }The visible rectangle in map coordinates covered by the current viewport.
enum VIEWPORT_LIGHTING_MODEGets or sets the v i e w p o r t_ l i g h t i n g_ m o d e.
float earthElevationGround elevation when viewport is used.
bool earthCloudLayerEnables/disables the cloud layer when viewport is used.
float earthCloudLayerSpeedSpeed of the cloud animation of cloud layer when viewport is used.
float earthCloudLayerElevationElevation of cloud layer when viewport is used.
float earthCloudLayerAlphaGlobal alpha for the optional cloud layer when viewport is used.
float earthCloudLayerShadowStrengthGlobal alpha for the optional cloud layer when viewport is used.
RectTransform renderViewportUIPanelPanel placeholder where viewport is positioned
Rect renderViewportRectFromSceneViewReturns the visible rectangle of the map represented by current SceneView viewport location and zoom
float renderViewportResolutionQuality of render viewport. This is a factor of the screen width. x2 is good for antialiasis. x1 equals to screen width.
int renderViewportResolutionMaxRTWidthMaximum width for the render texture. A value of 2048 is the recommended for most cases.
FilterMode renderViewportFilterModeGets or sets the render viewport filter mode.
VIEWPORT_LIGHTING_MODE renderViewportLightingModeGets or sets the render viewport lighting mode.
bool renderViewportFitScreenWidthEnsure the viewport is always visible and occupy the entire Window.
bool renderViewportFitScreenHeightEnsure the viewport is always visible and occupy the entire Window.
float renderViewportCurvatureCurvature of render viewport
float renderViewportCurvatureMinZoomCurvature of render viewport when zoom is at minimum
RenderingPath renderViewportRenderingPathGets or sets the render viewport rendering path.
LayerMask renderViewportLayerMaskGets or sets the render viewport layer mask.
float renderViewportTerrainAlphaGlobal alpha for the WMSK texture projectino on Unity terrain
float renderViewportGOAutoScaleMultiplierGlobal scale multiplier for game objects put on top of the viewport.
float renderViewportGOAutoScaleMinMinimum scale applied to game objects on the viewport.
float renderViewportGOAutoScaleMaxMaximum scale applied to game objects on the viewport.
GameObject sunGets or sets the sun.
bool sunUseTimeOfDayWhether the rotation of the Sun can be controlled using the timeOfDay property (0-24h)
float timeOfDaySimulated time of day (0-24). This would move the light gameobject orientation referenced by sun property around the map.
Methods
void SetViewportMode(bool enabled)Enables or disables viewport mode.
Vector2 ViewportToMapPosition(Vector3 worldPosition)Converts a 3D world position in the viewport to a 2D map coordinate.
Vector3 MapToViewportPosition(Vector2 mapPosition)Converts a 2D map coordinate to a 3D world position in the viewport.
float ComputeEarthHeight(Vector2 position, bool perspectiveAjusted)Computes the interpolated, perspective adjusted or not, height on given position.
bool RenderViewportGetNormal(Vector2 mapPosition, out Vector3 normal)Returns the surface normal of the renderViewport at the position in map coordinates.
bool RenderViewportGetNormal(Vector3 worldPosition, out Vector3 normal)Returns the surface normal of the renderViewport at the position in World coordinates.
float GetZoomExtents(Rect rect)Returns the zoom level required to show the entire rect in local map coordinates The country zoom level of -1 if error.
void EarthRaiseElevation(Vector2 localPosition, float radius, float amount)Increases heightmap value at specific position and radius amount to add/substract to heightmap. Heightmap values are in the 0-255 range (integer values).
void EarthLowerElevation(Vector2 position, float radius, float amount)Reduces heightmap value at specific position and radius
void EarthSetCustomElevation(Vector2 localPosition, float radius, float elevation)Increases heightmap value at specific position and radius
void EarthResetCustomElevation(Vector2 localPosition, float radius)Restores heightmap value at specific position and radius
Suggest an improvement
Help us improve this documentation page.