Programming Guide

intermediate scripting

World Map Globe Edition · Scripting Support (C#)

Class: All members documented in this section belong to the WorldMapGlobe component (namespace WPM). Access via WorldMapGlobe.instance.
Tip: The asset includes 50+ demo scenes with source code demonstrating all major features. Check the Demo folder for practical examples.

Getting Started

Add using WPM; at the top of your script. Access the globe singleton with:

using WPM;

WorldMapGlobe map = WorldMapGlobe.instance;

Namespace & Main Class

namespace WPM

All Globe Edition classes reside in the WPM namespace.

static WorldMapGlobe instance { get; }

Returns the singleton instance. One globe per scene.

Key Data Types

Country

Country entity with name, continent, regions (List<Region>), provinces, fipsCode, isoA2, isoA3, isoN3, hidden, customLabel, labelColor, attrib (JSONObject).

Province

Province/state entity with name, countryIndex, regions, center, attrib.

City

City with name, province, countryIndex, localPosition (Vector3 on sphere), population, cityClass.

Cell

Hexagonal grid cell with index, center (Vector3), visible, canCross, tag.

Region

A contiguous area of a country or province. Contains spherePoints (Vector3[]), center, neighbours, customMaterial.

MountPoint

Custom point of interest with name, type, countryIndex, provinceIndex, localPosition, customTags.

CallbackHandler

Return type for async operations (FlyTo, ZoomTo). Use .Then(callback) to chain actions after the operation completes.

Coordinate System

The globe uses sphere coordinates — Vector3 positions on a unit sphere centered at origin. The Conversion static class converts between sphere positions and latitude/longitude:

// Lat/Lon to sphere position
Vector3 spherePos = Conversion.GetSpherePointFromLatLon(40.4168f, -3.7038f);

// Sphere position to Lat/Lon
float lat, lon;
Conversion.GetLatLonFromSpherePoint(spherePos, out lat, out lon);

API Sections

The Globe API is organized into separate pages by category for easy reference. Each page covers a specific functional area — countries, provinces, cities, navigation, hex grid, fog of war, tile system, events, and more.

Basic Example

using UnityEngine;
using WPM;

public class GlobeExample : MonoBehaviour {
    WorldMapGlobe map;

    void Start() {
        map = WorldMapGlobe.instance;

        // Subscribe to country click
        map.OnCountryClick += (int countryIndex, int regionIndex) => {
            Country country = map.countries[countryIndex];
            Debug.Log("Clicked: " + country.name);
        };

        // Fly to Spain with bounce
        map.FlyToCountry("Spain", 2f, 0.2f);

        // Color France
        int france = map.GetCountryIndex("France");
        map.ToggleCountrySurface(france, true, new Color(0, 0, 1, 0.5f));
    }
}
Was this page helpful?