Core API

advanced scripting

Terrain Grid System 2 · Scripting Support (C#)

Note: This is an exhaustive index of public members for this API area. Signatures may vary by version; rely on your IDE/autocomplete and the source if needed.

API Reference

Grid Configuration

bool adjustCanvasSize

Adjust canvas size.

LayerMask blockingMask

Used to cancel highlighting then some other objects block raycasting (Review: verify this description matches current behavior.)

Bounds bounds

Bounds.

Bounds bounds

Bounds.

Rectangle bounds

Bounds.

Bounds bounds

Returns current bounds of grid in world space

int cellCount

Returns the actual number of cells created according to the current grid topology

int columnCount

Returns the number of columns for box and hexagonal grid topologies

float cornerJitter

Corner jitter.

bool disableMeshGeneration

Disable mesh generation.

CellDebugInfo displayCellDebugInfo

Shows cell information over the grid in Scene View

TerritoryDebugInfo displayTerritoryDebugInfo

Shows territory information over the grid in Scene View

bool enableGridEditor

Enabled grid editing options in Scene View

bool enableRectangleSelection

Enable rectangle selection.

bool evenLayout

Toggle even corner in hexagonal topology.

float gridCameraOffset

Grid camera offset.

Vector2 gridCenter

Center of the grid relative to the Terrain (by default, 0,0, which means center of terrain)

Vector3 gridCenterWorldPosition

Center of the grid in world space coordinates. You can also use this property to reposition the grid on a given world position coordinate.

float gridCurvature

Gets or sets the grid's curvature factor.

int gridDepthOffset

Grid depth offset.

Obsolete: Use gridMeshDepthOffset or gridSurfaceDepthOffset.

float gridElevation

Grid elevation.

float gridElevationBase

Grid elevation base.

float gridElevationCurrent

Grid elevation current.

Texture2D gridMask

Gets or sets the grid mask. The alpha component of this texture is used to determine cells visibility (0 = cell invisible)

int gridMaskInsideCount

Minimum number of vertices that must be inside the grid mask to consider the entire cell is inside the mask

bool gridMaskUseScale

When set to true, the mask will be mapped onto the scaled grid rectangle (using offset and scale parameters) instead of the full quad which ignores the offset and scale

int gridMeshDepthOffset

Grid mesh depth offset.

float gridMinElevationMultiplier

Grid min elevation multiplier.

float gridNormalOffset

Grid normal offset.

int gridRelaxation

Sets the relaxation iterations used to normalize cells sizes in irregular topology. (Review: verify this description matches current behavior.)

float gridRoughness

Grid roughness.

Vector2 gridScale

Scale of the grid on the Terrain (by default, 1,1, which means occupy entire terrain)

int gridSurfaceDepthOffset

Grid surface depth offset.

int gridSurfaceDepthOffsetTerritory

Grid surface depth offset territory.

GridTopology gridTopology

The grid type (boxed, hexagonal or irregular)

Vector3 localCursorLastClickedPosition

Returns the position of the last click on the grid (in local coordinates. Use transform.TransformPoint(x) to convert to world space)

Vector3 localCursorPosition

Returns the current cursor position in grid local coordinates (use transform.TransformPoint(x) to convert to world space)

bool pointyTopHexagons

Pointy top hexagons.

bool regularHexagons

Regular hexagons.

float regularHexagonsWidth

Regular hexagons width.

int rowCount

Returns the number of rows for box and hexagonal grid topologies

Vector3 screenCursorLastClickedPosition

Returns the screen position of the last click

int seed

Randomize seed used to generate territories. For Box/Hexagonal grids, changing seed only affects territory distribution. For Irregular grids, seed also affects cell positions unless voronoiSites are user-defined or Voronoi data is baked.

bool useGeometryShaders

When enabled, geometry shaders will be used (if platform supports them)

bool useStencilBuffer

When enabled, stencil buffer will be used to avoid overdraw and ensure correct rendering order of grid features. You can disable this option if it creates conflicts with other stencil-based renderers.

partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior
partial class TerrainGridSystem : MonoBehavior

Terrain & Elevation

int heightmapHeight

Heightmap height.

int heightmapHeight

Heightmap height.

int heightmapHeight

Heightmap height.

int heightmapWidth

Heightmap width.

int heightmapWidth

Heightmap width.

int heightmapWidth

Heightmap width.

bool multiTerrain

Multi terrain.

Terrain terrain

Terrain.

ITerrainWrapper terrain

Terrain.

Vector3 terrainCenter

Returns the terrain center in world space.

Vector2 terrainMeshPivot

Terrain mesh pivot.

GameObject terrainObject

Terrain reference. Assign a terrain to this property to fit the grid to terrain height and dimensions

LayerMask terrainObjectsLayerMask

Terrain objects layer mask.

string terrainObjectsPrefix

Terrain objects prefix.

bool terrainObjectsSearchGlobal

Terrain objects search global.

Highlight & Interaction

bool allowHighlightWhileDragging

Allow highlight while dragging.

GameObject highlightedObj

Returns a reference of the currently highlighted gameobject (cell or territory)

HighlightEffect highlightEffect

Highlight effect.

float highlightFadeAmount

Highlight fade amount.

float highlightFadeMin

Highlight fade min.

float highlightFadeSpeed

Highlight fade speed.

Texture2D highlightMask

Highlight mask.

float highlightMinimumTerrainDistance

Minimum distance from camera for cells to be highlighted on terrain

HighlightMode highlightMode

Highlight mode.

float highlightScaleMax

Highlight scale max.

float highlightScaleMin

Highlight scale min.

void HideHighlightedObject(GameObject go)

Used to cancel highlighting on a given gameobject. This call is ignored if go is not currently highlighted.

void HideHighlightedRegions()

Hides current highlighting effect

Visual Effects

float circularFadeDistance

Circular fade distance.

bool circularFadeEnabled

When enabled, grid is faded out according to distance to a gameoject

float circularFadeFallOff

Circular fade fall off.

Transform circularFadeTarget

The gameobject reference for the circular fade out effect

float farFadeDistance

Far fade distance.

bool farFadeEnabled

When enabled, lines far the camera will fade out gracefully

float farFadeFallOff

Far fade fall off.

float nearClipFade

Near clip fade.

bool nearClipFadeEnabled

When enabled, lines near the camera will fade out gracefully

float nearClipFadeFallOff

Near clip fade fall off.

Rendering

string animationSortingLayer

Sets the sorting layer for the animation effects such as fade out

int animationSortingOrder

Sets the sorting order for the animation effects such as fade out

Rect canvasRect

Canvas rect.

Texture2D canvasTexture

Canvas texture.

OverlayMode overlayMode

Overlay mode.

int sortingOrder

Sets the sorting layer for the grid elements (only valid when rendering in transparent queue)

Texture2D[] textures

Textures.

Texture2D[] textures

Textures.

bool transparentBackground

When enabled, grid is visible without background mesh

Input & Camera

Camera cameraMain

The camera reference used in certain computations

IInputProxy input

Access to the input class

TerrainGridSystem instance

Instance.

bool respectOtherUI

When enabled, will prevent interaction if pointer is over an UI element

Hit Testing

ContainsFunction Contains

Contains.

bool Contains(GameObject gameObject)

Performs contains.

bool Contains(GameObject gameObject)

Performs contains.

bool Contains(TriangulationPoint p)

Performs contains.

bool Contains(TriangulationPoint p)

Performs contains.

bool Contains(TriangulationPoint p)

Performs contains.

bool Contains(TriangulationPoint p)

Performs contains.

bool Contains(T value)

Performs contains.

bool Contains(bool value)

Performs contains.

bool Contains(Point2D p)

Performs contains.

bool Contains(double x, double y)

Returns whether the coordinate is inside the bounding box. Note that this will return false if the point is ON the edge of the bounding box. If you want to test for whether the point is inside OR on the rect, use ContainsInclusive

bool Contains(Point2D p)

Performs contains.

bool Contains(Rect2D r)

Performs contains.

bool Contains(Vector3 position)

Returns true if a given position lies within this grid on the X/Z plane

Utility Methods

void FitToScreen(Camera cam = null, float margin = 0f, bool keepAspectRatio = false)

Fits the grid to the current camera viewport on the grid plane. Works with both orthographic and perspective cameras.

Vector3 GetBottomLeftCornerPosition()

Returns the top/left corner of the grid in world space

IntRect GetBounds(Paths paths)

Gets bounds.

Bounds GetBounds()

Returns the bounds of the grid in world space coordinates.

Returns: The rect.

Rect GetRect()

Returns the rectangle area where cells are drawn in local coordinates.

Returns: The rect.

Vector2 GetSize()

Returns the size of the grid in world space coordinates.

void ReloadFlatMask()

Reloads flat mask.

void ReloadGridMask()

Reloads grid mask.

void ScaleSurface(GameObject surf, Vector2 center, float scale)

Escales the gameobject of a colored/textured surface

void SetBottomLeftCornerPosition(Vector3 position)

Sets the top/left position of the grid in world space

void SetDimensions(int rows, int columns, bool keepCellSize = false)

Sets the dimensions of the grid in one step. This is faster than setting rowCount and columnCount separately.

void SetDimensionsAndType(int rows, int columns, GridTopology gridTopology, bool keepCellSize = false)

Sets the dimensions of the grid in one step. This is faster than setting rowCount and columnCount separately.

void SetGridCenterWorldPosition(Vector3 position, bool snapToGrid)

Updates grid center position

void SetSize(double w, double h)

Sets size.

void SetSize(Vector2 size)

Sets the size of the grid in world space coordinates.

void SetTerrain(GameObject terrain)

Sets the terrain gameobject. This is equivalent to use the terrainObject property.

Vector3 SnapToCell(Vector3 position, bool worldSpace = true, bool snapToCenter = true)

Snaps a position to the grid (Review: verify this description matches current behavior.)

Enums

enum CellDebugInfo
enum CentroidType
enum GridTopology
enum HighlightEffect
enum HighlightMode
enum OverlayMode
enum TerritoryDebugInfo
Was this page helpful?