Additional Components

intermediate tasks

World Map 2D Edition · Common Tasks

Additional Components

World Map 2D Edition includes four extra components that extend the map's functionality. Each can be enabled from the Inspector (buttons at the bottom of the WorldMap2D component) or from code via accessor properties.

Calculator

Converts coordinates between different systems and calculates real-world distances.

Inspector

Calculator Inspector

Coordinate Conversion from Code

Access via map.calc. The conversion workflow:

  1. Set the source unit: calc.fromUnit = UNIT_TYPE.DecimalDegrees
  2. Assign source values: calc.fromLatDec = -15.281f
  3. Call calc.Convert()
  4. Read results from calc.to* fields
WorldMap2D map = WorldMap2D.instance;

// Convert from Decimal Degrees
map.calc.fromUnit = UNIT_TYPE.DecimalDegrees;
map.calc.fromLatDec = 40.4168f;
map.calc.fromLonDec = -3.7038f;
map.calc.Convert();
Debug.Log($"Plane: ({map.calc.toX}, {map.calc.toY})");

// Convert from Degrees (DMS)
map.calc.fromUnit = UNIT_TYPE.Degrees;
map.calc.fromLatDegrees = 40; map.calc.fromLatMinutes = 25; map.calc.fromLatSeconds = 0;
map.calc.fromLonDegrees = -3; map.calc.fromLonMinutes = 42; map.calc.fromLonSeconds = 14;
map.calc.Convert();

// Convert from Plane Coordinates
map.calc.fromUnit = UNIT_TYPE.PlaneCoordinates;
map.calc.fromX = 0.12f; map.calc.fromY = 0.34f;
map.calc.Convert();
Tip: Set map.calc.captureCursor = true to continuously convert the cursor position until set to false or the user presses C.

Distance Calculator

Calculate real-world distance in meters between two points:

// By coordinates
float dist = map.calc.Distance(40.4168f, -3.7038f, 48.8566f, 2.3522f);

// By city objects
float dist = map.calc.Distance(city1, city2);

Ticker

Displays scrolling or static text banners over the map. Useful for news tickers, alerts, and notifications.

Inspector

Ticker Inspector

Ticker Bands

There are 9 available ticker bands (configurable). Each band has:

PropertyDescription
Scroll SpeedSet to 0 for a static band.
Auto-HideHides the band when no texts remain.
Fade SpeedHow quickly the band appears/disappears. Set to 0 to disable.
Vertical OffsetPosition of the band on the map.

Ticker Text Options

PropertyDescription
Horizontal OffsetPosition offset (0 = center, range -0.5 to 0.5).
Fade DurationSet to 0 to disable fading.
Blink IntervalSet to 0 to disable blinking. Repetitions = 0 blinks forever.

Ticker API

WorldMap2D map = WorldMap2D.instance;
map.ticker.ResetTickerBands();

// Configure a red static band
TickerBand band = map.ticker.tickerBands[0];
band.verticalOffset = 0.2f;
band.backgroundColor = new Color(1, 0, 0, 0.9f);
band.scrollSpeed = 0;   // static
band.visible = true;
band.autoHide = true;

// Add a blinking text
TickerText text = new TickerText(0, "WARNING!!");
text.textColor = Color.yellow;
text.blinkInterval = 0.2f;
text.horizontalOffset = 0.1f;
text.duration = 10f;
map.ticker.AddTickerText(text);

// Configure a scrolling blue band
TickerBand band2 = map.ticker.tickerBands[1];
band2.verticalOffset = 0.1f;
band2.verticalSize = 0.05f;
band2.backgroundColor = new Color(0, 0, 1, 0.9f);
band2.visible = true;
band2.autoHide = true;

TickerText text2 = new TickerText(1, "INCOMING MESSAGE!!");
text2.textColor = Color.white;
map.ticker.AddTickerText(text2);

Ticker API Reference

int NUM_TICKERS

Number of available ticker band slots.

bool overlayMode

When enabled, ticker texts display on top of everything at the camera's near clip distance.

int GetTickerTextCount() / GetTickerTextCount(int bandIndex)

Returns the number of active ticker texts (total or per band).

int GetTickerBandsActiveCount()

Returns the number of visible ticker bands.

void ResetTickerBands() / ResetTickerBand(int index)

Resets all bands (or a specific band) to defaults and removes their texts.

void AddTickerText(TickerText text)

Adds a ticker text to the specified band.

Decorator

Customizes the visual appearance of individual countries: labels, colors, and textures.

Decorator Inspector

Decorator API

void SetCountryDecorator(int groupIndex, string countryName, CountryDecorator decorator)

Assigns a decorator to a country within a group. Groups let you enable/disable multiple decorators at once.

void RemoveCountryDecorator(int groupIndex, string countryName)

Removes a decorator and its visual effects from the group.

CountryDecorator Properties

PropertyDescription
customLabelCustom label text (empty string = keep default).
isColorizedWhether the country is filled with color.
fillColorThe fill color.
labelOverridesColor / labelColorOverride the label color.
labelVisibleWhether the label is visible (default: true).
labelOffsetHorizontal/vertical offset relative to country center.
labelRotationLabel rotation in degrees.
textureTexture to apply to the country surface.
textureScale / textureOffset / textureRotationTexture mapping adjustments.

Map Editor

An in-editor tool for modifying borders, countries, provinces, and cities interactively. Open it by clicking Open Editor at the bottom of the WorldMap2D inspector.

Note: The Map Editor works only in Edit mode, not during Play mode.
Map Editor Inspector

Configuration

SettingDescription
Show LayersChoose whether to visualize countries only or countries + provinces.
Country FileLow-definition (110M:1) or high-definition (30M:1) geodata file.
City FilePrincipal cities only, or principal + medium-sized cities.

Toolbar Modes

ModeDescription
SelectClick to select any country, province, or city in the Scene View.
ReshapeModify borders with Point, Circle, Split, Magnet, Smooth, Erase, and Delete tools.
CreateCreate new cities, provinces, or countries.
RevertDiscards changes and reloads data from geodata files.
SaveSaves changes to files in Resources/Geodata.

Reshape Tools

Reshape tools
ToolDescription
PointMove one point at a time. Neighbor points move together to maintain shared borders.
CircleMoves all points inside a radius. Points nearer the center move faster unless Constant Move is checked.
SplitV / SplitHSplits the region vertically or horizontally, creating a new entity named "New [original]".
MagnetClick points from different regions to fuse them. Aggressive Mode moves all circle points to nearest neighbors and removes duplicates.
SmoothAdds new points around the border for smoother curves.
EraseRemoves points inside the selection circle.
DeleteDeletes the selected region (or the entire entity if no regions remain).

Create Mode

Create mode

Countries and provinces consist of one or more regions. You can add new regions to an existing entity or create entirely new countries/provinces. The main region is always the largest by area.

Gear Menu Options

Gear menu
OptionDescription
Restore BackupRestores original geodata files from the Backup folder (created on first save).
Create Low Def GeodataGenerates a simplified low-definition file from the high-definition geodata (only available when editing high-def).

World Flags & Weather Symbols

Available as a separate purchase, this package includes 270+ vector and raster country flag images. Flag file names match the country names used in the map, enabling easy texture mapping:

WorldMap2D map = WorldMap2D.instance;
string countryName = "China";

Texture2D flag = Resources.Load<Texture2D>("Flags/png/" + countryName);
int idx = map.GetCountryIndex(countryName);
map.ToggleCountryMainRegionSurface(idx, true, flag);
Was this page helpful?