World Map Globe Edition · Scripting Support (C#)
WorldMapGlobe (namespace WPM). Access via WorldMapGlobe.instance.
bool showHexagonalGrid { get; set; }Show or hide the hexagonal grid on the globe.
int hexaGridDivisions { get; set; }Number of grid divisions (15-400). Higher values = more cells.
Color hexaGridColor { get; set; }Grid line color.
Color hexaGridHighlightColor { get; set; }Highlighted cell color.
bool hexaGridHighlightEnabled { get; set; }Enable cell highlighting on hover.
bool hexaGridGenerateInBackgroundThread { get; set; }Generate the grid in a background thread (avoids frame stutter).
bool hexaGridUseMask { get; set; }Apply a mask texture to limit where cells appear.
Texture2D hexaGridMask { get; set; }The mask texture (white = visible, black = hidden).
int hexaGridMaskThreshold { get; set; }Mask threshold (0-255).
Vector3 hexaGridRotationShift { get; set; }Rotation offset for the hex grid.
Cell[] cells { get; }Array of all grid cells.
Cell lastHighlightedCell { get; }The last cell highlighted by the user.
int GetCellIndex(Vector3 spherePosition)Returns the cell index at a sphere position.
int GetCellIndex(float latitude, float longitude)Returns the cell index at lat/lon coordinates.
Cell[] GetCellNeighbors(int cellIndex)Returns the neighboring cells.
bool ShowCell(int cellIndex)Makes a cell visible.
bool HideCell(int cellIndex)Hides a cell.
bool ToggleCell(int cellIndex, bool visible)Toggles cell visibility.
bool IsCellVisible(int cellIndex)Returns whether a cell is visible.
bool SetCellColor(int cellIndex, Color color, bool temporary = false)Sets a cell's color. If temporary, resets when deselected.
bool SetCellTexture(int cellIndex, Texture2D texture, bool temporary = false)Sets a cell's texture.
bool SetCellMaterial(int cellIndex, Material mat, bool temporary = false)Sets a cell's material.
HeuristicFormula pathFindingHeuristicFormula { get; set; }Heuristic formula for A* pathfinding (Manhattan, Euclidean, etc.).
int pathFindingSearchLimit { get; set; }Maximum number of cells to search.
int pathFindingSearchMaxCost { get; set; }Maximum traversal cost for pathfinding.
List<int> FindPath(int cellIndexStart, int cellIndexEnd, int searchLimit = 0)Finds a path between two cells. Returns a list of cell indices, or null if no path exists.
List<int> FindPath(Vector3 startPosition, Vector3 endPosition, int searchLimit = 0)Finds a path between two sphere positions.
bool SetCellCanCross(int cellIndex, bool canCross)Sets whether a cell can be traversed by pathfinding.
bool GetCellCanCross(int cellIndex)Returns whether a cell is traversable.
bool SetCellNeighborCost(int cellIndex, int cellNeighborIndex, int cost, bool bothSides = true)Sets the traversal cost between two adjacent cells.
void SetCellNeighborsCost(int cellIndex, int cost, bool bothSides = true)Sets the traversal cost to all neighbors of a cell.
int GetCellNeighborCost(int cellIndex, int neighborIndex)Returns the traversal cost between two adjacent cells.
using UnityEngine;
using WPM;
using System.Collections.Generic;
public class HexGridExample : MonoBehaviour {
void Start() {
WorldMapGlobe map = WorldMapGlobe.instance;
// Enable hex grid
map.showHexagonalGrid = true;
map.hexaGridDivisions = 50;
map.hexaGridHighlightEnabled = true;
// Block some cells
map.SetCellCanCross(100, false);
map.SetCellColor(100, Color.red);
// Find a path
List<int> path = map.FindPath(0, 200);
if (path != null) {
foreach (int cellIndex in path) {
map.SetCellColor(cellIndex, Color.green);
}
}
}
}
Help us improve this documentation page.