Events
intermediate conceptsWorld Map Strategy Kit · Core Concepts
General map events
Subscribe on the WMSK instance. Example: WMSK.instance.OnClick += handler;
event OnMouseClick OnClick(float x, float y, int buttonIndex)Fired when the map is clicked.
event OnMouseClick OnMouseDown(float x, float y, int buttonIndex)Fired when a mouse button is pressed on the map.
event OnMouseClick OnMouseRelease(float x, float y, int buttonIndex)Fired when a mouse button is released on the map.
event OnMouseEvent OnMouseMove(float x, float y)Fired when the mouse moves over the map.
event OnSimpleMapEvent OnFlyStart()Fired when a FlyTo operation begins.
event OnSimpleMapEvent OnFlyEnd()Fired when a FlyTo operation completes.
event OnSimpleMapEvent OnDragStart()Fired when the user begins dragging the map.
event OnSimpleMapEvent OnDragEnd()Fired when the user stops dragging the map.
Country events
event OnCountryEvent OnCountryEnter(int countryIndex, int regionIndex)Fired when the pointer enters a country.
event OnCountryEvent OnCountryExit(int countryIndex, int regionIndex)Fired when the pointer leaves a country.
event OnCountryClickEvent OnCountryClick(int countryIndex, int regionIndex, int buttonIndex)Fired when a country is clicked.
event OnCountryHighlightEvent OnCountryHighlight(int countryIndex, int regionIndex, ref bool allowHighlight)Fired when a country is about to be highlighted. Set allowHighlight to false to prevent it.
Province events
event OnProvinceEvent OnProvinceEnter(int provinceIndex, int regionIndex)Fired when the pointer enters a province.
event OnProvinceEvent OnProvinceExit(int provinceIndex, int regionIndex)Fired when the pointer leaves a province.
event OnProvinceClickEvent OnProvinceClick(int provinceIndex, int regionIndex, int buttonIndex)Fired when a province is clicked.
event OnProvinceHighlightEvent OnProvinceHighlight(int provinceIndex, int regionIndex, ref bool allowHighlight)Fired when a province is about to be highlighted. Set allowHighlight to false to prevent it.
Region (country or province) events
event OnRegionClickEvent OnRegionClick(Region region, int buttonIndex)Fired when any region (country or province) is clicked.
event OnRegionEvent OnRegionEnter(Region region)Fired when the pointer enters any region.
event OnRegionEvent OnRegionExit(Region region)Fired when the pointer leaves any region.
City events
event OnCityEnter OnCityEnter(int cityIndex)Fired when the pointer enters a city.
event OnCityEnter OnCityExit(int cityIndex)Fired when the pointer leaves a city.
event OnCityClick OnCityClick(int cityIndex, int buttonIndex)Fired when a city is clicked.
Grid cell events
event OnCellEvent OnCellEnter(int cellIndex)Fired when the pointer enters a grid cell.
event OnCellEvent OnCellExit(int cellIndex)Fired when the pointer leaves a grid cell.
event OnCellClickEvent OnCellClick(int cellIndex, int buttonIndex)Fired when a grid cell is clicked.
Path-finding events
These events let you modify traversal costs during path-finding. Return a custom cost value (0 = blocked, higher = more expensive).
event OnPathFindingCrossPosition OnPathFindingCrossPosition(Vector2 position)Called when the path crosses a map position. Return a cost multiplier.
event OnPathFindingCrossAdminEntity OnPathFindingCrossCountry(int entityIndex)Called when the path crosses into a country. Return a cost multiplier.
event OnPathFindingCrossAdminEntity OnPathFindingCrossProvince(int entityIndex)Called when the path crosses into a province. Return a cost multiplier.
event OnPathFindingCrossCell OnPathFindingCrossCell(int cellIndex)Called when the path crosses a grid cell. Return a cost multiplier.
Tile events
OnTileRequestEvent OnTileRequest(int zoomLevel, int x, int y, out Texture2D texture, out string error)Intercept tile loading requests. Return true and provide a Texture2D to supply your own tile.
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 or proxying.
Map gameobject (VGO) events
Global events fired on the WMSK instance for all viewport gameobjects (units).
Action<GameObjectAnimator> OnVGOPointerEnter(GameObjectAnimator anim)Fired when the pointer enters a viewport gameobject.
Action<GameObjectAnimator> OnVGOPointerExit(GameObjectAnimator anim)Fired when the pointer leaves a viewport gameobject.
Action<GameObjectAnimator> OnVGOPointerDown(GameObjectAnimator anim)Fired when a mouse button is pressed on a viewport gameobject.
Action<GameObjectAnimator> OnVGOPointerUp(GameObjectAnimator anim)Fired when a mouse button is released on a viewport gameobject.
Action<GameObjectAnimator> OnVGOPointerRightDown(GameObjectAnimator anim)Fired when the right mouse button is pressed on a viewport gameobject.
Action<GameObjectAnimator> OnVGOPointerRightUp(GameObjectAnimator anim)Fired when the right mouse button is released on a viewport gameobject.
Action<GameObjectAnimator> OnVGOMoveStart(GameObjectAnimator anim)Fired when a viewport gameobject starts moving.
Action<GameObjectAnimator> OnVGOMove(GameObjectAnimator anim)Fired each frame while a viewport gameobject is moving.
Action<GameObjectAnimator> OnVGOMoveEnd(GameObjectAnimator anim)Fired when a viewport gameobject reaches its destination.
Action<GameObjectAnimator> OnVGOCountryEnter(GameObjectAnimator anim)Fired when a viewport gameobject enters a country.
Action<GameObjectAnimator> OnVGOCountryRegionEnter(GameObjectAnimator anim)Fired when a viewport gameobject enters a country region.
Action<GameObjectAnimator> OnVGOProvinceEnter(GameObjectAnimator anim)Fired when a viewport gameobject enters a province.
Action<GameObjectAnimator> OnVGOProvinceRegionEnter(GameObjectAnimator anim)Fired when a viewport gameobject enters a province region.
Action<GameObjectAnimator> OnVGOKilled(GameObjectAnimator anim)Fired when a viewport gameobject is destroyed via DestroyUnit().
Action<GameObjectAnimator> OnVGOVisibleChange(GameObjectAnimator anim)Fired when a viewport gameobject's visibility state changes (enabled/disabled by the viewport system).
Marker events
Events for 2D sprites and 3D markers added to the map. Enable events when adding the marker:
map.AddMarker2DSprite(star, planeLocation, 0.02f, enableEvents: true);
map.OnMarkerMouseDown += (marker, buttonIndex) => Debug.Log("Click on " + marker.name);
OnMarkerPointerClickEvent OnMarkerMouseDown(MarkerClickHandler marker, int buttonIndex)Fired when a mouse button is pressed on a marker.
OnMarkerPointerClickEvent OnMarkerMouseUp(MarkerClickHandler marker, int buttonIndex)Fired when a mouse button is released on a marker.
OnMarkerEvent OnMarkerMouseEnter(MarkerClickHandler marker)Fired when the pointer enters a marker.
OnMarkerEvent OnMarkerMouseExit(MarkerClickHandler marker)Fired when the pointer leaves a marker.
OnMarkerEvent OnMarkerDragStart(MarkerClickHandler marker)Fired when a marker drag operation begins.
OnMarkerEvent OnMarkerDragEnd(MarkerClickHandler marker)Fired when a marker drag operation ends.
Per-unit events on GameObjectAnimator
The GameObjectAnimator component (attached to each unit) exposes its own set of events. These fire on the individual unit instead of the map.
GameObjectAnimator goa = unit.WMSK_MoveTo(...);
goa.OnMoveEnd += (anim) => Debug.Log(anim.name + " arrived");
goa.OnVisibleChange += (anim) => Debug.Log(anim.name + " visibility changed");
event GOEvent OnMoveStart(GameObjectAnimator anim)Fired when the unit starts moving.
event GOEvent OnMove(GameObjectAnimator anim)Fired each frame while the unit is moving.
event GOEvent OnMoveEnd(GameObjectAnimator anim)Fired when the unit reaches its destination.
event GOEvent OnKilled(GameObjectAnimator anim)Fired when the unit is destroyed.
event GOEvent OnPointerEnter(GameObjectAnimator anim)Fired when the pointer enters this unit.
event GOEvent OnPointerExit(GameObjectAnimator anim)Fired when the pointer leaves this unit.
event GOEvent OnPointerDown(GameObjectAnimator anim)Fired when a mouse button is pressed on this unit.
event GOEvent OnPointerUp(GameObjectAnimator anim)Fired when a mouse button is released on this unit.
event GOEvent OnPointerRightDown(GameObjectAnimator anim)Fired when the right mouse button is pressed on this unit.
event GOEvent OnPointerRightUp(GameObjectAnimator anim)Fired when the right mouse button is released on this unit.
event GOEvent OnCountryEnter(GameObjectAnimator anim)Fired when this unit enters a country.
event GOEvent OnProvinceEnter(GameObjectAnimator anim)Fired when this unit enters a province.
event GOEvent OnCountryRegionEnter(GameObjectAnimator anim)Fired when this unit enters a country region.
event GOEvent OnProvinceRegionEnter(GameObjectAnimator anim)Fired when this unit enters a province region.
event GOEvent OnVisibleChange(GameObjectAnimator anim)Fired when this unit's visibility state changes.
Per-unit events on GameObjectAnimator
The GameObjectAnimator component (attached to each unit) exposes its own set of events. These mirror most VGO events but fire on the individual unit instead of the map. Subscribe directly on the GOA instance:
GameObjectAnimator goa = unit.WMSK_MoveTo(...);
goa.OnVisibleChange += (anim) => Debug.Log(anim.name + " visibility changed");
public event GOEvent OnMoveStart;
public event GOEvent OnMove;
public event GOEvent OnMoveEnd;
public event GOEvent OnKilled;
public event GOEvent OnPointerEnter;
public event GOEvent OnPointerExit;
public event GOEvent OnPointerDown;
public event GOEvent OnPointerUp;
public event GOEvent OnPointerRightDown;
public event GOEvent OnPointerRightUp;
public event GOEvent OnCountryEnter;
public event GOEvent OnProvinceEnter;
public event GOEvent OnCountryRegionEnter;
public event GOEvent OnProvinceRegionEnter;
public event GOEvent OnVisibleChange;Suggest an improvement
Help us improve this documentation page.