Scripting Support (C#)
advanced scriptingWorld Map Globe Ultra Edition · Scripting Support (C#)
The components and the settings classes are in the WPM namespace. The geodata types (PoliticalMap, CITY_CLASS), the coordinates (Double3, PlanetCoordinates) and FlightPose are in WPM.Planetary.
using WPM;
using WPM.Planetary;
Latitudes and longitudes are in degrees. Altitudes are in meters above sea level, over a sphere of 6,371 km of radius. In the Vector2 arrays and results, X is the latitude and Y is the longitude.
Settings Objects
The options of the inspector are fields of the globe and of these settings objects. See Globe Settings for each field.
| Field | Description |
|---|---|
PlanetarySkySettings sky | Date and time of the sky, stars, Moon, planets and constellations. |
PlanetaryAtmosphereSettings atmosphere | Sun light, atmosphere, lens flare and Sun shadows. |
PlanetaryPoliticalSettings political | Countries, provinces, names and cities. political.cacheMegabytes (16 to 256, default 96) is the video memory of the political map, read when the component is enabled. |
PlanetaryBuildingsSettings buildings | Buildings. |
PlanetaryTreesSettings trees | Trees. |
PlanetaryCloudsSettings clouds | Clouds. |
PlanetaryGeocodingSettings geocoding | Service of the address search. Only from scripts. |
A change of a field shows in the next frame, except for the options that are read when the component is enabled.
WorldMapGlobeUltra: Properties
| Property | Description |
|---|---|
PlanetaryFlightCamera flightCamera | Camera that flies over the globe. |
string Attribution | Credits of the data sources in use. Your application must show this text. |
DateTime SkyTime | Date and time of the sky in UTC. |
FlightPose AnticipatedView | View that the camera will have soon, whose terrain is prepared in advance. Null by default. |
PoliticalMap Map | Countries, provinces and cities of the geodata. Null while it loads. |
countries, provinces, cities | Lists of the geodata, the same as Map.Countries, Map.Provinces and Map.Cities. |
int countryHighlightedIndex, provinceHighlightedIndex | Highlighted country and province, or -1. |
int MarkerCount | Number of markers, lines and texts that you added. |
int AnchorCount | Number of anchored objects. |
int VisibleTiles, BlendingTiles | Terrain tiles drawn now, and tiles that change their shape now. |
int PendingDownloads, FailedDownloads | Downloads that wait or run now, and downloads that failed since the component was enabled. |
string LastDownloadIssue | Text of the last download problem, or null. |
string StatusText | Short text with the state of the terrain under the camera. |
DrawnBuildingChunks, PendingBuildingTiles, DownloadedBuildingBytes, BuildingsRelease | State of the buildings. See Buildings. |
DrawnTrees, DrawnTreeChunks, PendingTreeBlocks, DownloadedTreeBytes | State of the trees. See Trees. |
SunShadowRedraws, SunReliefRedraws, SunReliefTiles, SunAirFills | Counters of the work of the Sun shadows, for diagnostics. |
WorldMapGlobeUltra: Countries and Provinces
| Method | Description |
|---|---|
int GetCountryIndex(string name) | Country by its name, or -1. |
int GetCountryIndexByISO_A2(string), GetCountryIndexByISO_A3(string), GetCountryIndexByISO_N3(string), GetCountryIndexByFIPS10_4(string) | Country by its ISO or FIPS code, or -1. |
int GetCountryIndex(double latitude, double longitude) | Country at a place, or -1. |
bool GetCountryIndex(Ray ray, out int countryIndex) | Country under a ray of the camera. |
int GetProvinceIndex(int countryIndex, string name) | Province by its name inside a country, or -1. |
int GetProvinceIndex(double latitude, double longitude) | Province at a place, or -1. |
bool GetProvinceIndex(Ray ray, out int provinceIndex) | Province under a ray of the camera. |
bool GetGlobeIntersection(Ray ray, out double latitude, out double longitude [, out double altitude]) | Place where a ray meets the drawn surface, relief included. |
void ToggleCountrySurface(int countryIndex, bool visible, Color color) | Colors a country or removes its color. |
void ToggleProvinceSurface(int provinceIndex, bool visible, Color color) | Colors a province or removes its color. |
void HideCountrySurface(int), HideProvinceSurface(int) | Removes the color of a country or of a province. |
void HideCountrySurfaces(), HideProvinceSurfaces() | Removes all the colors of the countries or of the provinces. |
void HighlightCountry(int countryIndex [, Color color]) | Highlights a country. |
void HighlightProvince(int provinceIndex [, Color color]) | Highlights a province. |
void HideCountryRegionHighlights(), HideProvinceRegionHighlights() | Removes the highlight. |
void BlinkCountry(int countryIndex, Color color1, Color color2, float duration, float blinkingSpeed, bool smoothBlink = false) | Makes a country blink. |
void BlinkProvince(int provinceIndex, Color color1, Color color2, float duration, float blinkingSpeed, bool smoothBlink = false) | Makes a province blink. |
void DrawProvinceLabels(int countryIndex, Color color = default), DrawProvinceLabels(string countryName, Color color = default) | Names of the provinces of a country, with Visibility set to Scripting. |
void HideProvinceLabels() | Hides the names drawn with DrawProvinceLabels. |
WorldMapGlobeUltra: Cities
| Method | Description |
|---|---|
PoliticalMap.City GetCity(...) | A city by index, by country and name, or null. |
int GetCityIndex(...) | A city by name (the most populated city with that name), by country and name, by country, province and name, by place, by city object, or by a ray of the camera. |
int GetCityIndexInCountry(...), GetCityIndexInProvince(int provinceIndex, string cityName) | A city by its name inside a country or a province. |
string[] GetCityNames(...) | Names of all the cities, or of the cities of a country. |
string GetCityCountryName(int), GetCityProvinceName(int), GetCityFullName(int) | Names of the country and of the province of a city, and its full name. |
Vector2 GetCityLatLon(int cityIndex) | Place of a city. |
GetCountryCapital(...), GetCountryCapitalIndex(...) | Capital of a country, by index or by name. |
void FlyToCity(...) | Flies to a view of a city. |
CITY_CLASS_FILTER_REGION_CAPITAL_CITY, CITY_CLASS_FILTER_COUNTRY_CAPITAL_CITY | Values of political.cityClassAlwaysShow. |
See City Methods for every overload.
WorldMapGlobeUltra: Markers and Texts
| Method | Description |
|---|---|
PlanetaryMarker AddMarker(PlanetaryMarkerType.Circle, ...) | Circle or ring with a radius in kilometers. |
PlanetaryMarker AddMarker(PlanetaryMarkerType.Quad, ...) | Quad between two corners. |
PlanetaryMarker AddLine(...) | Line through points or between two places. |
PlanetaryMarker AddPolygon3D(Vector2[] latlon, Color borderColor, Color fillColor = default) | Polygon. |
PlanetaryMarker AddText(string text, double latitude, double longitude, Color color, float kmSize, float heading = 90) | Text on the ground. |
void ClearMarker(PlanetaryMarker), ClearLineMarker(PlanetaryMarker) | Removes one marker or line. |
void ClearMarkers(), ClearLineMarkers() | Removes all the markers that are not lines, or all the lines. |
See Markers & Texts for the members of PlanetaryMarker.
WorldMapGlobeUltra: Constellations
| Member | Description |
|---|---|
int constellationCount | Number of constellations, or 0 while the sky is not ready. |
int GetConstellationIndex(string nameOrCode) | Constellation by its name or its code of three letters, or -1. |
bool GetConstellationIndex(Ray ray, out int constellationIndex [, out int starIndex, float maxPixels]) | Constellation, and star with a name, near a ray of the camera. |
string GetConstellationName(int), GetConstellationCode(int), GetStarName(int) | Names and codes. |
Vector3 GetConstellationDirection(int constellationIndex) | Direction of a constellation in the scene. |
void LookAtConstellation(int), LookAtConstellation(string) | Turns the camera to a constellation. |
void HighlightConstellation(int constellationIndex, int starIndex = -1), ClearConstellationHighlight() | Highlights a constellation, or ends the highlight. |
int constellationHighlighted, starHighlighted | Highlighted constellation and star, or -1. |
See Constellations for each member.
WorldMapGlobeUltra: Other Methods
| Method | Description |
|---|---|
void GetLocation(string address, Action<GeocodingResult> onResult) | Finds the place of a postal address. |
void FlyToAddress(string address, double altitude = 600, float duration = 0, Action<GeocodingResult> onResult = null) | Flies to a view of a postal address. |
void ReloadBuildings() | Loads the buildings files again. |
void ReloadTrees() | Loads the tree prefab again. |
PlanetaryFlightCamera
| Member | Description |
|---|---|
void FlyToLocation(double latitude, double longitude, double altitude, double seconds = 0) | Flies to a view of a place. |
bool IsFlying | True during a flight. |
void StopFlight() | Ends the flight. |
void SetLocation(double lat, double lon, double altitude) | Moves the camera at once to a place and ends a flight. |
FlightPose Pose | Position, orientation and velocity of the camera in planet coordinates. |
Camera View | The Unity camera. |
double SurfaceClearance | Height over the drawn ground in meters. |
bool ignoreKeys | Ignores the keys that move the camera, for example while the user writes in a text field. |
See Flight Camera for the fields of the inspector.
PlanetaryInteraction
| Member | Description |
|---|---|
OnCityEnter, OnCityExit, OnCityPointerDown, OnCityPointerUp, OnCityClick | Events of the cities. |
OnCountryEnter, OnCountryExit, OnCountryPointerDown, OnCountryPointerUp, OnCountryClick | Events of the countries. |
OnProvinceEnter, OnProvinceExit, OnProvincePointerDown, OnProvincePointerUp, OnProvinceClick | Events of the provinces. |
OnConstellationEnter, OnConstellationExit, OnConstellationClick, OnStarEnter, OnStarExit | Events of the constellations and of the stars with a name. |
cityUnderPointer, countryUnderPointer, provinceUnderPointer, countryRegionUnderPointer, provinceRegionUnderPointer | What is under the pointer, or -1. |
constellationUnderPointer, starUnderPointer | Constellation and star under the pointer, or -1. |
cityLastClicked, countryLastClicked, provinceLastClicked | Last clicked city, country and province, or -1. |
void UpdatePointer(Vector2 screenPosition, bool pressed, bool secondaryPressed = false) | Gives the pointer from your own code. |
globe, readPointer, cityPickPixels, cityPickOffset, constellationPickPixels | Settings of the component. |
See Pointer Events for the arguments of the events.
PlanetaryAnchor
| Member | Description |
|---|---|
void SetLocation(double latitude, double longitude, double altitude) | Moves the object to a place. |
globe, latitude, longitude, altitude, altitudeReference, orientation, heading | Settings of the component. |
Double3 PlanetPosition, double GroundHeight, bool OnDrawnGround | Where the globe placed the object, and the ground under it. |
PoliticalDataColors
| Member | Description |
|---|---|
bool Apply(), bool Apply(string csvText) | Colors the regions from the table of the component or from a text. |
void Clear() | Removes the colors. |
Color ColorOf(double value) | Color of a value. |
legend, matchedRows, unmatchedRows, rangeMinimum, rangeMaximum, error | Result of the last table. |
event Action OnChanged | Raised after a table is applied or cleared. |
Coming from World Map Globe Edition
The options and the methods that mean the same as in World Map Globe Edition have its names, for example tileServer, tileServerCustomUrl, tileMaxZoomLevel, tileMaxConcurrentDownloads, tileMaxLocalCacheSize, political.frontiersThickness, countries, provinces, cities, HighlightCountry, ToggleCountrySurface, BlinkCountry, AddMarker, AddLine, GetCityIndex and FlyToCity. These are the main differences:
- The places are latitudes and longitudes, not positions on a sphere.
- The pointer events are in the
PlanetaryInteractioncomponent, not in the globe. - The markers return a
PlanetaryMarker, not a GameObject, and their type isPlanetaryMarkerType. - The globe does not draw cities: use anchored objects to show them.
- Your own objects are placed with a
PlanetaryAnchor, not as children of the globe.
Suggest an improvement
Help us improve this documentation page.