Core API
advanced scriptingTerrain Grid System 2 · Scripting Support (C#)
API Reference
Grid Configuration
bool adjustCanvasSizeAdjust canvas size.
LayerMask blockingMaskUsed to cancel highlighting then some other objects block raycasting (Review: verify this description matches current behavior.)
Bounds boundsBounds.
Bounds boundsBounds.
Rectangle boundsBounds.
Bounds boundsReturns current bounds of grid in world space
int cellCountReturns the actual number of cells created according to the current grid topology
int columnCountReturns the number of columns for box and hexagonal grid topologies
float cornerJitterCorner jitter.
bool disableMeshGenerationDisable mesh generation.
CellDebugInfo displayCellDebugInfoShows cell information over the grid in Scene View
TerritoryDebugInfo displayTerritoryDebugInfoShows territory information over the grid in Scene View
bool enableGridEditorEnabled grid editing options in Scene View
bool enableRectangleSelectionEnable rectangle selection.
bool evenLayoutToggle even corner in hexagonal topology.
float gridCameraOffsetGrid camera offset.
Vector2 gridCenterCenter of the grid relative to the Terrain (by default, 0,0, which means center of terrain)
Vector3 gridCenterWorldPositionCenter of the grid in world space coordinates. You can also use this property to reposition the grid on a given world position coordinate.
float gridCurvatureGets or sets the grid's curvature factor.
int gridDepthOffsetGrid depth offset.
Obsolete: Use gridMeshDepthOffset or gridSurfaceDepthOffset.
float gridElevationGrid elevation.
float gridElevationBaseGrid elevation base.
float gridElevationCurrentGrid elevation current.
Texture2D gridMaskGets or sets the grid mask. The alpha component of this texture is used to determine cells visibility (0 = cell invisible)
int gridMaskInsideCountMinimum number of vertices that must be inside the grid mask to consider the entire cell is inside the mask
bool gridMaskUseScaleWhen 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 gridMeshDepthOffsetGrid mesh depth offset.
float gridMinElevationMultiplierGrid min elevation multiplier.
float gridNormalOffsetGrid normal offset.
int gridRelaxationSets the relaxation iterations used to normalize cells sizes in irregular topology. (Review: verify this description matches current behavior.)
float gridRoughnessGrid roughness.
Vector2 gridScaleScale of the grid on the Terrain (by default, 1,1, which means occupy entire terrain)
int gridSurfaceDepthOffsetGrid surface depth offset.
int gridSurfaceDepthOffsetTerritoryGrid surface depth offset territory.
GridTopology gridTopologyThe grid type (boxed, hexagonal or irregular)
Vector3 localCursorLastClickedPositionReturns the position of the last click on the grid (in local coordinates. Use transform.TransformPoint(x) to convert to world space)
Vector3 localCursorPositionReturns the current cursor position in grid local coordinates (use transform.TransformPoint(x) to convert to world space)
bool pointyTopHexagonsPointy top hexagons.
bool regularHexagonsRegular hexagons.
float regularHexagonsWidthRegular hexagons width.
int rowCountReturns the number of rows for box and hexagonal grid topologies
Vector3 screenCursorLastClickedPositionReturns the screen position of the last click
int seedRandomize 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 useGeometryShadersWhen enabled, geometry shaders will be used (if platform supports them)
bool useStencilBufferWhen 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 : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorpartial class TerrainGridSystem : MonoBehaviorTerrain & Elevation
int heightmapHeightHeightmap height.
int heightmapHeightHeightmap height.
int heightmapHeightHeightmap height.
int heightmapWidthHeightmap width.
int heightmapWidthHeightmap width.
int heightmapWidthHeightmap width.
bool multiTerrainMulti terrain.
Terrain terrainTerrain.
ITerrainWrapper terrainTerrain.
Vector3 terrainCenterReturns the terrain center in world space.
Vector2 terrainMeshPivotTerrain mesh pivot.
GameObject terrainObjectTerrain reference. Assign a terrain to this property to fit the grid to terrain height and dimensions
LayerMask terrainObjectsLayerMaskTerrain objects layer mask.
string terrainObjectsPrefixTerrain objects prefix.
bool terrainObjectsSearchGlobalTerrain objects search global.
Highlight & Interaction
bool allowHighlightWhileDraggingAllow highlight while dragging.
GameObject highlightedObjReturns a reference of the currently highlighted gameobject (cell or territory)
HighlightEffect highlightEffectHighlight effect.
float highlightFadeAmountHighlight fade amount.
float highlightFadeMinHighlight fade min.
float highlightFadeSpeedHighlight fade speed.
Texture2D highlightMaskHighlight mask.
float highlightMinimumTerrainDistanceMinimum distance from camera for cells to be highlighted on terrain
HighlightMode highlightModeHighlight mode.
float highlightScaleMaxHighlight scale max.
float highlightScaleMinHighlight 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 circularFadeDistanceCircular fade distance.
bool circularFadeEnabledWhen enabled, grid is faded out according to distance to a gameoject
float circularFadeFallOffCircular fade fall off.
Transform circularFadeTargetThe gameobject reference for the circular fade out effect
float farFadeDistanceFar fade distance.
bool farFadeEnabledWhen enabled, lines far the camera will fade out gracefully
float farFadeFallOffFar fade fall off.
float nearClipFadeNear clip fade.
bool nearClipFadeEnabledWhen enabled, lines near the camera will fade out gracefully
float nearClipFadeFallOffNear clip fade fall off.
Rendering
string animationSortingLayerSets the sorting layer for the animation effects such as fade out
int animationSortingOrderSets the sorting order for the animation effects such as fade out
Rect canvasRectCanvas rect.
Texture2D canvasTextureCanvas texture.
OverlayMode overlayModeOverlay mode.
int sortingOrderSets the sorting layer for the grid elements (only valid when rendering in transparent queue)
Texture2D[] texturesTextures.
Texture2D[] texturesTextures.
bool transparentBackgroundWhen enabled, grid is visible without background mesh
Input & Camera
Camera cameraMainThe camera reference used in certain computations
IInputProxy inputAccess to the input class
TerrainGridSystem instanceInstance.
bool respectOtherUIWhen enabled, will prevent interaction if pointer is over an UI element
Hit Testing
ContainsFunction ContainsContains.
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 CellDebugInfoenum CentroidTypeenum GridTopologyenum HighlightEffectenum HighlightModeenum OverlayModeenum TerritoryDebugInfoSuggest an improvement
Help us improve this documentation page.