Terrain Grid System 2 · Scripting Support (C#)
bool allowTerritoriesInsideTerritoriesSet this property to true to allow territories to be surrounded by other territories.
float colorizedTerritoriesAlphaColorized territories alpha.
bool colorizeTerritoriesToggle colorize countries. (Review: verify this description matches current behavior.)
int numTerritoriesGets or sets the number of initial territories.
bool showTerritoriesToggle frontiers visibility. (Review: verify this description matches current behavior.)
bool showTerritoriesInteriorBordersToggle interior frontiers visibility. (Review: verify this description matches current behavior.)
bool showTerritoriesOuterBordersShows perimetral/outer border of territories?
List<Territory> territoriesTerritories.
float territoriesAsymmetryDetermines the distribution of cells among territories
TerritoryColorScheme territoriesColorSchemeHow colors for territories are picked
int territoriesColorSeedSeed used to generate random territory fill colors.
Color[] territoriesFillColorsUser defined territory colors
bool territoriesHideNeutralCellsGets or sets if neutral cells are visible.
bool territoriesIgnoreHiddenCellsSet this property to true to allow territories to be surrounded by other territories.
int[] territoriesInitialCellIndicesGets or sets the cell indices for the first cells of territories during generation.
TerritoryInitialCellMethod territoriesInitialCellMethodGets or sets the number of initial territories.
int territoriesMaxIterationsMaximum number of iterations when generation territories
int territoriesMaxRangeMaximum distance in cell units from the origin cell when generating territories. 0 = only origin cells.
float territoriesOrganicMakes territory contour more organic
Texture2D territoriesTextureTerritories texture.
Color territoriesTextureNeutralColorTerritories texture neutral color.
bool territoryCustomBorderThicknessEnables territory custom border thickness
Color territoryDisputedFrontierColorTerritories disputed borders color
float territoryFrontiersAlphaTerritory frontiers alpha.
Color territoryFrontiersColorTerritories border color
bool territoryFrontiersMiterJoinsUses miter joins for territory frontier thick lines (avoids gaps/overlaps at corners when geometry shaders are not used)
float territoryFrontiersThicknessTerritory frontier thickness
Color territoryHighlightColorFill color to use when the mouse hovers a territory's region.
Color territoryHighlightColor2Alternate fill color to use when the mouse hovers a territory's region.
Territory territoryHighlightedReturns Territory under mouse position or null if none.
int territoryHighlightedIndexReturns currently highlighted territory index in the countries list.
int territoryHighlightedRegionIndexReturns currently highlighted territory region index.
bool territoryInteriorBorderIncludeEnclavesShow interior borders on top of regular territory borders.
bool territoryInteriorBorderOnTopShow interior borders on top of regular territory borders.
float territoryInteriorBorderPaddingTerritory interior border padding
float territoryInteriorBorderThicknessTerritory interior border thickness
int territoryLastClickedIndexReturns Territory index which has been clicked
int territoryRegionLastClickedIndexReturns Territory region index which has been clicked
int TerritoryGetAdjacentCells(int territoryIndex, List<int> cellIndices, int regionIndex = -1, int otherTerritoryIndex = -1)Similar to TerritoryGetFrontierCells but returns the cells of the adjacent territory
bool TerritoryGetAdjacentTerritoryForEdge(int territoryIndex, Vector2 vertex1, Vector2 vertex2, out int adjacentTerritoryIndex, out int adjacentTerritoryRegionIndex)Returns the adjacent territory and region index for a given edge defined by two vertices.
Returns: True if an adjacent territory was found, false otherwise
Territory TerritoryGetAtLocalPosition(Vector3 position)Returns the territory object under position in local coordinates
Territory TerritoryGetAtLocalPosition(Vector3 position, out int regionIndex)Returns the territory object under position in local coordinates
Territory TerritoryGetAtPosition(Vector2 localPosition)Returns the territory object under position in local coordinates
Deprecated: Use TerritoryGetAtWorldPosition or TerritoryGetAtLocalPosition instead.
Territory TerritoryGetAtPosition(Vector3 position, bool worldSpace)Deprecated: Use TerritoryGetAtWorldPosition or TerritoryGetAtLocalPosition instead.
Returns the territory object under position in local or worldSpace coordinates.
Territory TerritoryGetAtWorldPosition(Vector3 position)Returns the territory object under position in worldSpace coordinates
Territory TerritoryGetAtWorldPosition(Vector3 position, out int regionIndex)Returns the territory object under position in worldSpace coordinates
List<Cell> TerritoryGetCells(int territoryIndex)Returns a copy of all cells belonging to a territory. Use Territory.cells to access the list without making a copy
void TerritoryGetCells(int territoryIndex, List<Cell> cells)Returns all cells belonging to a territory into an user given list. See alto territory.cells list.
List<Cell> TerritoryGetCells(int territoryIndex, int regionIndex)Returns all cells belonging to a territory region
void TerritoryGetCells(int territoryIndex, int regionIndex, List<Cell> cells)Returns all cells belonging to a territory region into an user given cell list
List<Vector2> TerritoryGetFrontier(int territoryIndex, int regionIndex)Returns the points that form the frontier of a territory/region (a territory usually has a single region but could include more than one if it gets split) Points returned already have the offset and scale of the grid applied
int TerritoryGetFrontierCells(int territoryIndex, List<int> cellIndices, int regionIndex = -1, bool includeGridEdges = false)Returns a list of cells that form the frontiers of a given territory
Returns: The number of cells found.
int TerritoryGetFrontierCells(int territoryIndex, int otherTerritoryIndex, List<int> cellIndices, int regionIndex = -1, bool includeGridEdges = false)Returns a list of cells that forms the frontiers between a given territory and another one.
Returns: The get frontier cells.
GameObject TerritoryGetGameObject(int territoryIndex, int regionIndex = 0)Returns the shape/surface gameobject of the territory.
Returns: The get game object.
List<Territory> TerritoryGetNeighbors(int territoryIndex)Returns a list of neighbor territories for specificed cell index.
int TerritoryGetNeighbors(int territoryIndex, List<Territory> territories)Returns a list of neighbor territories for specificed territory index in the territories parameter.
Vector3 TerritoryGetPosition(int territoryIndex, CentroidType centroidType = CentroidType.BetterCentroid, bool worldSpace = true, int regionIndex = 0)Gets the territory's center position in world space.
Vector3 TerritoryGetPosition(Territory territory, CentroidType centroidType = CentroidType.BetterCentroid, bool worldSpace = true, int regionIndex = 0)Gets the territory's center position in world space.
Bounds TerritoryGetRectWorldSpace(int territoryIndex, int regionIndex = 0)Returns the rect enclosing the territory in world space
int TerritoryGetVertexCount(int territoryIndex, int regionIndex = 0)Returns the number of vertices of the territory
Vector3 TerritoryGetVertexPosition(int territoryIndex, int vertexIndex, int regionIndex = 0)Returns the world space position of the vertex of a territory
bool TerritoryIsNeutral(int territoryIndex)Returns true if territory is neutral
bool TerritoryIsVisible(int territoryIndex)Returns true if territory is visible
Territory TerritoryCreate(Cell cell)Create a new territory with a single cell
Returns: The newly created territory
Territory TerritoryCreate(int cellIndex)Create a new territory with a single cell
Returns: The newly created territory
Territory TerritoryCreate(List<Cell> cells)Create a new territory from a list of cells
Returns: The newly created territory
Territory TerritoryCreate(List<int> cellIndices)Create a new territory from a list of cells
Returns: The newly created territory
bool TerritoryDestroy(int territoryIndex)Removes an existing territory. Cells belonging to the territory will be freed.
Returns: True if successful
void TerritoryDestroyAll()Destroys all territories
enum TerritoryInitialCellMethodvoid TerritorySetBorderVisible(int territoryIndex, bool visible)Specifies if a given territory border is visible.
GameObject TerritorySetColor(Territory territory, Color color, int regionIndex = 0)Sets the color of a territory
GameObject TerritorySetColor(int territoryIndex, Color color, int regionIndex = 0)Sets the color of a territory
void TerritorySetFrontierColor(int territoryIndex, Color color)Specifies the color of the territory borders.
GameObject TerritorySetMaterial(int territoryIndex, Material material, int regionIndex = 0)Assigns a custom material to a territory
void TerritorySetNeutral(int territoryIndex, bool neutral)Specifies if a given territory is neutral.
GameObject TerritorySetTexture(Territory territory, Texture2D texture, int regionIndex = 0)Sets the texture of a territory
GameObject TerritorySetTexture(int territoryIndex, Texture2D texture, int regionIndex = 0)Sets the texture of a territory
void TerritorySetVisible(int territoryIndex, bool visible, bool includeCells = false)Specifies if a given territory is visible.
void TerritoryUpdateFillColors()If territory color scheme is set to user-defined, copy those settings into current territories and redraw
enum TerritoryColorSchemeGameObject TerritoryDrawFrontier(Territory territory, int adjacentTerritoryIndex = -1, Material material = null, Color color = default(Color), float thickness = 0)Creates a gameobject with the frontier for the given territory. Optionally, the frontier could be limited to those segments adjacent to another territory.
GameObject TerritoryDrawFrontier(int territoryIndex, int adjacentTerritoryIndex = -1, Material material = null, Color color = default, float thickness = 0, bool removeExistingCustomFrontiers = true)Creates a gameobject with the frontier for the given territory. Optionally, the frontier could be limited to those segments adjacent to another territory.
GameObject TerritoryDrawInteriorBorder(int territoryIndex, float padding, float thickness, Color color = default, Color secondColor = default, int regionIndex = 0, float animationSpeed = 0, bool includeEnclaves = false)Creates a gameobject with the interior border for the given territory with optional padding and thickness.
Returns: The gameobject of the border
GameObject TerritoryDrawInteriorBorder(Territory territory, float padding = -0.7f, float thickness = 3f, Color color = default, Color secondColor = default, int regionIndex = 0, float animationSpeed = 0, bool includeEnclaves = false, bool removeExistingBorders = true)Creates a gameobject with the interior border for the given territory with optional padding and thickness.
Returns: The gameobject of the border
GameObject TerritoryDrawInteriorBorder(Territory territory, int regionIndex, float padding = -0.7f, float thickness = 3f, Color color = default, Color secondColor = default, float animationSpeed = 0, bool includeEnclaves = false, bool removeExistingBorders = true)Creates a gameobject with the interior border for the given territory with optional padding and thickness.
Returns: The gameobject of the border
void TerritoryHideInteriorBorder(int territoryIndex, int regionIndex = -1)Hides territory border of a territory
void TerritoryHideInteriorBorders()Hides all territories interior boders
void TerritoryHideRegionSurface(int territoryIndex, int regionIndex = 0)Uncolorize/hide specified territory by index in the territories collection.
void TerritoryHideRegionSurfaces()Uncolorize/hide all territories.
void TerritoryScaleSurface(int territoryIndex, float scale, int regionIndex = 0)Scales the gameobject of a colored/textured surface (Review: verify this description matches current behavior.)
void TerritoryToggleRegionSurface(int territoryIndex, bool visible, int regionIndex = 0)Toggles visibility of a territory surface.
GameObject TerritoryToggleRegionSurface(Territory territory, bool visible, Color color, bool refreshGeometry = false, int regionIndex = 0)Colorize specified territory by index.
GameObject TerritoryToggleRegionSurface(int territoryIndex, bool visible, Color color, bool refreshGeometry = false, int regionIndex = 0)Colorize specified territory by index.
GameObject TerritoryToggleRegionSurface(int territoryIndex, bool visible, Color color, bool refreshGeometry, Texture2D texture, int regionIndex = 0)Colorize specified territory by index.
GameObject TerritoryToggleRegionSurface(int territoryIndex, bool visible, Color color, bool refreshGeometry, Texture2D texture, Vector2 textureScale, Vector2 textureOffset, float textureRotation, bool rotateInLocalSpace, int regionIndex = 0, bool isCanvasTexture = false)Colorize specified territory by index.
GameObject TerritoryToggleRegionSurface(Territory territory, bool visible, Color color, bool refreshGeometry, Texture2D texture, Vector2 textureScale, Vector2 textureOffset, float textureRotation, bool overlay, bool rotateInLocalSpace, int regionIndex = 0, bool isCanvasTexture = false)Colorize specified territory by index.
GameObject TerritoryToggleRegionSurface(int territoryIndex, bool visible, Color color, bool refreshGeometry, Texture2D texture, Vector2 textureScale, Vector2 textureOffset, float textureRotation, bool overlay, bool rotateInLocalSpace, int regionIndex = 0, bool isCanvasTexture = false)Colorize specified territory by index.
void TerritoryBlink(int territoryIndex, Color color, float duration, int repetitions = 1)Blinks a territory with "color" and "duration" in seconds.
void TerritoryBlink(List<Territory> territories, Color color, float duration, int repetitions = 1)Blinks a list of territories with "color" and "duration" in seconds.
void TerritoryBlink(List<int> territoryIndices, Color color, float duration, int repetitions = 1)Blinks a list of territories with "color" and "duration" in seconds.
void TerritoryCancelAnimations(int territoryIndex, float fadeOutDuration = 0)Cancels any ongoing visual effect on a territory
void TerritoryCancelAnimations(List<Territory> territories, float fadeOutDuration = 0)Cancels any ongoing visual effect on a list of territories
void TerritoryCancelAnimations(List<int> territoryIndices, float fadeOutDuration = 0)Cancels any ongoing visual effect on a list of territories
void TerritoryColorTemp(int territoryIndex, Color color, float duration)Temporarily colors a territory for "duration" in seconds.
void TerritoryColorTemp(List<Territory> territories, Color color, float duration)Temporarily colors a list of territories for "duration" in seconds.
void TerritoryColorTemp(List<int> territoryIndices, Color color, float duration)Temporarily colors a list of territories for "duration" in seconds.
void TerritoryFadeOut(int territoryIndex, Color color, float duration, int repetitions = 1)Colors a territory and fades it out during "duration" in seconds.
void TerritoryFadeOut(List<Territory> territories, Color color, float duration, int repetitions = 1)Colors a list of territories with "color" and "duration" in seconds.
void TerritoryFadeOut(List<int> territoryIndices, Color color, float duration, int repetitions = 1)Colors a list of territories with "color" and "duration" in seconds.
void TerritoryFlash(int territoryIndex, Color color, float duration, int repetitions = 1)Flashes a territory with "color" and "duration" in seconds.
void TerritoryFlash(List<Territory> territories, Color color, float duration, int repetitions = 1)Flashes a list of territories with "color" and "duration" in seconds.
void TerritoryFlash(List<int> territoryIndices, Color color, float duration, int repetitions = 1)Flashes a list of territories with "color" and "duration" in seconds.
void ExportTerritoriesMesh()Exports all territories as independent meshes
void ExportTerritoryMesh(int territoryIndex, int regionIndex = 0)Exports the specified territory mesh
void SetNumTerritories(int numTerritories, bool preserveCells)Recreate territories and optionally keep current cells
void ToggleTerritories(bool visible)Enables/disables territory rendering
Help us improve this documentation page.