Events
advanced scriptingWorld Map Globe Edition · Scripting Support (C#)
WorldMapGlobe (namespace WPM). Subscribe via WorldMapGlobe.instance.
Country Events
event CountryBeforeEnterEvent OnCountryBeforeEnter(int countryIndex, int regionIndex, ref bool ignoreCountry)Fired before a country is entered. Can be used to prevent highlighting.
event CountryEvent OnCountryEnter(int countryIndex, int regionIndex)Fired when the pointer enters a country.
event CountryEvent OnCountryExit(int countryIndex, int regionIndex)Fired when the pointer exits a country.
event CountryClickEvent OnCountryClick(int countryIndex, int regionIndex, int buttonIndex)Fired when a country is clicked.
event CountryClickEvent OnCountryPointerDown(int countryIndex, int regionIndex, int buttonIndex)Fired on mouse button down over a country.
event CountryClickEvent OnCountryPointerUp(int countryIndex, int regionIndex, int buttonIndex)Fired on mouse button up over a country.
Province Events
event ProvinceBeforeEnter OnProvinceBeforeEnter(int provinceIndex, int regionIndex, ref bool ignoreProvince)Fired before a province is entered.
event ProvinceEvent OnProvinceEnter(int provinceIndex, int regionIndex) / OnProvinceExitProvince enter and exit events.
event ProvinceClickEvent OnProvinceClick(int provinceIndex, int regionIndex, int buttonIndex) / OnProvincePointerDown / OnProvincePointerUpProvince click and pointer events.
City Events
event CityEvent OnCityEnter(int cityIndex) / OnCityExitCity enter and exit events.
event CityClickEvent OnCityClick(int cityIndex, int buttonIndex) / OnCityPointerDown / OnCityPointerUpCity click and pointer events.
Continent Events
event ContinentEvent OnContinentEnter(string continent) / OnContinentExitContinent enter and exit events.
event ContinentClickEvent OnContinentClick(string continent, int buttonIndex) / OnContinentPointerDown / OnContinentPointerUpContinent click and pointer events.
Globe Interaction Events
event GlobeClickEvent OnClick(Vector3 sphereLocation, int mouseButtonIndex)Fired when the globe is clicked. Provides the sphere position.
event GlobeClickEvent OnMouseDown(Vector3 sphereLocation, int mouseButtonIndex) / OnMouseReleaseMouse button down and release over the globe.
event GlobeEvent OnDrag(Vector3 sphereLocation)Fired continuously during drag operations.
event GlobeEvent OnFlyStart(Vector3 sphereLocation) / OnFlyEndFired when a FlyTo animation starts and ends.
event SimpleEvent OnOrbitRotateStart() / OnOrbitRotateEndOrbit rotation animation start and end.
event ZoomEvent OnZoomStart(float zoomLevel) / OnZoomEndZoom animation start and end.
event RaycastEvent OnRaycast()Fired on each raycast against the globe. Useful for custom interaction logic.
Grid Cell Events
event GridCellEvent OnCellEnter(int cellIndex) / OnCellExitFired when the pointer enters or exits a hex grid cell.
event GridCellClickEvent OnCellClick(int cellIndex, int buttonIndex)Fired when a hex grid cell is clicked.
Pathfinding Events
event PathFindingEvent OnPathFindingCrossCell(int cellIndex)Fired when the pathfinder crosses a hex grid cell during route calculation.
Tile Events
event TileRequestEvent OnTileRequest(int zoomLevel, int x, int y, out Texture2D texture, out string error)Fired when a tile needs to be loaded.
event TileMapVisibleEvent OnTileRecomputed(List<TileInfo> visibleTiles)Fired when the visible tile set is recalculated.
event TileEvent OnTileCreated(TileInfo ti)Fired when a tile is created.
event TileEvent OnTileBecameVisible(TileInfo ti) / OnTileBecameInvisibleTile visibility change events.
event TileURLRequestEvent OnTileURLRequest(string url, TILE_SERVER server, int zoomLevel, int x, int y)Override the URL used to download a tile. Useful for custom tile providers.
Line Marker Events (LineMarkerAnimator)
The LineMarkerAnimator component (namespace WPM) is attached to animated line markers created via AddLine(). Assign callbacks to react to line drawing or fade completion:
LineEvent OnLineDrawingEnd(LineMarkerAnimator lma)Fired when the line drawing animation completes.
LineEvent OnLineFadeOut(LineMarkerAnimator lma)Fired when the line fade-out animation completes (just before the line GameObject is destroyed).
Code Example
using UnityEngine;
using WPM;
public class EventExample : MonoBehaviour {
void Start() {
WorldMapGlobe map = WorldMapGlobe.instance;
// Country events
map.OnCountryEnter += (int countryIndex, int regionIndex) => {
Debug.Log("Entered: " + map.countries[countryIndex].name);
};
map.OnCountryClick += (int countryIndex, int regionIndex) => {
map.ToggleCountrySurface(countryIndex, true,
new Color(0, 1, 0, 0.3f));
};
// Globe click (raw position)
map.OnClick += (Vector3 spherePos) => {
float lat, lon;
Conversion.GetLatLonFromSpherePoint(spherePos, out lat, out lon);
Debug.Log($"Clicked at {lat:F2}, {lon:F2}");
};
// Hex cell events
map.OnCellClick += (int cellIndex, int buttonIndex) => {
map.SetCellColor(cellIndex, Color.yellow);
};
}
}
Suggest an improvement
Help us improve this documentation page.