Put a marker on the map
Annotations are shapes you draw on top of the map from code: a marker on a chest, a route, a zone. Each one
returns an id (an int) that you keep to move or remove it. Places are Coordinates, so a scene
position works. You can call these before the map is loaded.
int flag = map.AddPoint(chest.position, Color.yellow, size: 16, label: "Old chest");
Points, lines, areas
|
A round marker. |
|
A line through at least two places, for a route. |
|
A filled area around at least three places. Half-transparent red by default. |
color is optional and red by default. A call with too few places throws an ArgumentException.
int route = map.AddLine(new[] { (MapCoordinate)start.position, camp.position, goal.position }, Color.cyan);
Move or remove
map.MovePoint(flag, chest.position); // only for markers made with AddPoint
map.RemoveAnnotation(flag); // false if there was no such id
map.ClearAnnotations(); // everything
Move a marker every frame
int id;
void Start() { id = map.AddPoint(transform.position, Color.red); }
void Update() { map.MovePoint(id, transform.position); }
Calling it every frame is fine. For an icon or portrait that follows an object, the Map Icon component does it without code (Minimap and world map).
Limits
Only markers made with AddPoint take a text (label), in one font and colour. For a styled text, a portrait
or a button, place UI over the map with map.MapToScreen (Clicks and the pointer) or the Map Icon
component (Minimap and world map).