Events & Input Callbacks
advanced scriptingTerrain Grid System 2 · Scripting Support (C#)
API Reference
Cell Events
event CellClickEvent OnCellClick(TerrainGridSystem tgs, int cellIndex, int buttonIndex)Occurs when user releases the mouse button on the same cell that started clicking
event CellDragEvent OnCellDrag(TerrainGridSystem tgs, int cellOriginIndex, int cellTargetIndex)Occurs when user drags a cell
event CellDragEvent OnCellDragEnd(TerrainGridSystem tgs, int cellOriginIndex, int cellTargetIndex)Occurs when user ends drag on a cell
event CellEvent OnCellDragStart(TerrainGridSystem tgs, int cellIndex)Occurs when user starts dragging on a cell
event CellEvent OnCellEnter(TerrainGridSystem tgs, int cellIndex)Occurs when the pointer enters a cell
event CellEvent OnCellExit(TerrainGridSystem tgs, int cellIndex)Occurs when the pointer exits a cell
event CellHighlightEvent OnCellHighlight(TerrainGridSystem tgs, int cellIndex, ref bool cancelHighlight)Occurs when a cell is about to get highlighted
event CellClickEvent OnCellMouseDown(TerrainGridSystem tgs, int cellIndex, int buttonIndex)Occurs when user presses the mouse button on a cell
event CellClickEvent OnCellMouseUp(TerrainGridSystem tgs, int cellIndex, int buttonIndex)Occurs when user releases the mouse button on any cell
Territory Events
event TerritoryClickEvent OnTerritoryClick(TerrainGridSystem tgs, int territoryIndex, int regionIndex, int buttonIndex)Occurs when user releases the mouse button on the same territory that started clicking
event TerritoryEvent OnTerritoryEnter(TerrainGridSystem tgs, int territoryIndex)Occurs when the pointer enters a territory
event TerritoryEvent OnTerritoryExit(TerrainGridSystem tgs, int territoryIndex)Occurs when the pointer exits a territory
event TerritoryHighlightEvent OnTerritoryHighlight(TerrainGridSystem tgs, int territoryIndex, ref bool cancelHighlight)Occurs when a territory is about to get highlighted
event TerritoryClickEvent OnTerritoryMouseDown(TerrainGridSystem tgs, int territoryIndex, int regionIndex, int buttonIndex)Occurs when user press the mouse button on a territory
event TerritoryClickEvent OnTerritoryMouseUp(TerrainGridSystem tgs, int territoryIndex, int regionIndex, int buttonIndex)Occurs when user releases the mouse button on a territory
event TerritoryRegionClickEvent OnTerritoryRegionClick(TerrainGridSystem tgs, int territoryIndex, int regionIndex, int buttonIndex)Occurs when user releases the mouse button on the same territory region that started clicking
event TerritoryRegionEvent OnTerritoryRegionEnter(TerrainGridSystem tgs, int territoryIndex, int regionIndex)Occurs when the pointer enters a territory region
event TerritoryRegionEvent OnTerritoryRegionExit(TerrainGridSystem tgs, int territoryIndex, int regionIndex)Occurs when the pointer exits a territory region
event TerritoryRegionClickEvent OnTerritoryRegionMouseDown(TerrainGridSystem tgs, int territoryIndex, int regionIndex, int buttonIndex)Occurs when user press the mouse button on a territory region
event TerritoryRegionClickEvent OnTerritoryRegionMouseUp(TerrainGridSystem tgs, int territoryIndex, int regionIndex, int buttonIndex)Occurs when user releases the mouse button on a territory region
Pathfinding Events
event PathFindingEvent OnPathFindingCrossCell(TerrainGridSystem tgs, int cellIndex)Fired when path finding algorithmn evaluates a cell. Use this event to return any extra cost for crossing the cell or 0 to keep the cost at 1.
PathFindingEvent OnPathFindingCrossCell(TerrainGridSystem tgs, int cellIndex)On path finding cross cell.
Selection Events
RectangleSelectionEvent OnRectangleDrag(TerrainGridSystem tgs, Vector2 localStartPos, Vector2 localEndPos)Occurs when user starts draggins a rectangle selection
RectangleSelectionEvent OnRectangleSelection(TerrainGridSystem tgs, Vector2 localStartPos, Vector2 localEndPos)Occurs when user performs a rectangle selection
GridMove Helper Events
The GridMove component (namespace TGS) is attached to GameObjects moved via CellMoveTo(). Subscribe on the returned component:
event MoveEvent OnMoveEnd(GameObject gameObject)Triggered when the MoveTo operation finishes and the GameObject reaches its destination.
event CellMoveEvent OnCellMove(GameObject gameObject, Vector3 destination, int pathIndex, List<int> path)Triggered when the GameObject moves into the next cell along its path.
Delegate Types
delegate void CellClickEvent(TerrainGridSystem tgs, int cellIndex, int buttonIndex)delegate void CellDragEvent(TerrainGridSystem tgs, int cellOriginIndex, int cellTargetIndex)delegate void CellEvent(TerrainGridSystem tgs, int cellIndex)delegate void CellHighlightEvent(TerrainGridSystem tgs, int cellIndex, ref bool cancelHighlight)delegate void ClickEvent(TerrainGridSystem tgs, Vector3 worldPosition)delegate void GridEvent(TerrainGridSystem tgs)delegate void GridSettingsChangedEvent(TerrainGridSystem tgs)event ClickEvent OnClick(TerrainGridSystem tgs, Vector3 worldPosition)Event callback.
event GridEvent OnEnter(TerrainGridSystem tgs)Event callback.
event GridEvent OnExit(TerrainGridSystem tgs)Event callback.
event GridSettingsChangedEvent OnGridSettingsChanged(TerrainGridSystem tgs)Occurs when some grid settings are changed
event ClickEvent OnMouseDown(TerrainGridSystem tgs, Vector3 worldPosition)Event callback.
event ClickEvent OnMouseUp(TerrainGridSystem tgs, Vector3 worldPosition)Event callback.
delegate float PathFindingEvent(TerrainGridSystem tgs, int cellIndex, object data = null)delegate void RectangleSelectionEvent(TerrainGridSystem tgs, Vector2 localStartPos, Vector2 localEndPos)delegate void TerritoryClickEvent(TerrainGridSystem tgs, int territoryIndex, int regionIndex, int buttonIndex)delegate void TerritoryEvent(TerrainGridSystem tgs, int territoryIndex)delegate void TerritoryHighlightEvent(TerrainGridSystem tgs, int territoryIndex, ref bool cancelHighlight)delegate void TerritoryRegionClickEvent(TerrainGridSystem tgs, int territoryIndex, int regionIndex, int buttonIndex)delegate void TerritoryRegionEvent(TerrainGridSystem tgs, int territoryIndex, int regionIndex)Suggest an improvement
Help us improve this documentation page.