Viewport API

advanced scripting

World Map Strategy Kit · Scripting Support (C#)

Class: 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_MODE

Gets or sets the v i e w p o r t_ l i g h t i n g_ m o d e.

float earthElevation

Ground elevation when viewport is used.

bool earthCloudLayer

Enables/disables the cloud layer when viewport is used.

float earthCloudLayerSpeed

Speed of the cloud animation of cloud layer when viewport is used.

float earthCloudLayerElevation

Elevation of cloud layer when viewport is used.

float earthCloudLayerAlpha

Global alpha for the optional cloud layer when viewport is used.

float earthCloudLayerShadowStrength

Global alpha for the optional cloud layer when viewport is used.

RectTransform renderViewportUIPanel

Panel placeholder where viewport is positioned

Rect renderViewportRectFromSceneView

Returns the visible rectangle of the map represented by current SceneView viewport location and zoom

float renderViewportResolution

Quality of render viewport. This is a factor of the screen width. x2 is good for antialiasis. x1 equals to screen width.

int renderViewportResolutionMaxRTWidth

Maximum width for the render texture. A value of 2048 is the recommended for most cases.

FilterMode renderViewportFilterMode

Gets or sets the render viewport filter mode.

VIEWPORT_LIGHTING_MODE renderViewportLightingMode

Gets or sets the render viewport lighting mode.

bool renderViewportFitScreenWidth

Ensure the viewport is always visible and occupy the entire Window.

bool renderViewportFitScreenHeight

Ensure the viewport is always visible and occupy the entire Window.

float renderViewportCurvature

Curvature of render viewport

float renderViewportCurvatureMinZoom

Curvature of render viewport when zoom is at minimum

RenderingPath renderViewportRenderingPath

Gets or sets the render viewport rendering path.

LayerMask renderViewportLayerMask

Gets or sets the render viewport layer mask.

float renderViewportTerrainAlpha

Global alpha for the WMSK texture projectino on Unity terrain

float renderViewportGOAutoScaleMultiplier

Global scale multiplier for game objects put on top of the viewport.

float renderViewportGOAutoScaleMin

Minimum scale applied to game objects on the viewport.

float renderViewportGOAutoScaleMax

Maximum scale applied to game objects on the viewport.

GameObject sun

Gets or sets the sun.

bool sunUseTimeOfDay

Whether the rotation of the Sun can be controlled using the timeOfDay property (0-24h)

float timeOfDay

Simulated 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

Was this page helpful?