Class MapMarker
Makes an object appear on the minimap and the world map. Attach to any prefab — a character, an NPC, a gathering node, a door — that players should be able to find.
public class MapMarker : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourMapMarker
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Remarks
What replaced what. This supersedes the old MinimapIcon, which
spawned a child SpriteRenderer onto a dedicated "Minimap" layer at a fixed world
height of 999 so that an overhead camera would photograph it. That approach could not do
most of what a map needs — a sprite in a render texture has no label, no tooltip, cannot be
clamped to the edge of the frame when its object is off screen, and scales with the map's
zoom instead of staying legible. Worse, it made map visibility a property of a Unity layer:
anything on that layer was on the map, whether or not the player was supposed to know where
it was, and the only way to hide one thing from one player was to move a GameObject between
layers at runtime.
What this does instead. The component is data and a registration; it spawns nothing and renders nothing. The client's map panels read MapMarkerRegistry, apply Visibility against the local player's relationship to this object, and draw the survivors as UI elements. Every marker is therefore filtered by a rule the map subsystem owns, and gains labels, tooltips, edge clamping and zoom-independent sizing for free.
Server builds. Registration is compiled out under UNITY_SERVER. The
component still exists there so shared prefabs deserialise identically on both sides —
stripping the type would make every prefab that carries one log a missing-script warning on
the server — but it holds no state and does no work.
Fields
ClampToEdge
Whether the marker is pinned to the edge of the frame, pointing at its object, when the object is outside the current view.
[Tooltip("Pin the marker to the frame edge, pointing at the object, when it is off the map view.")]
public bool ClampToEdge
Field Value
Icon
Icon drawn for this marker. Falls back to the type's default when null.
[Tooltip("Icon drawn for this marker. Uses the type's default icon when empty.")]
public Sprite Icon
Field Value
- Sprite
IconSize
Size of the icon in UI points at the map's base scale.
[Tooltip("Size of the icon in UI points at the map's base scale.")]
public float IconSize
Field Value
Label
Text drawn beside the icon. Empty means no label.
[Tooltip("Static text drawn beside the icon. Leave empty for no label.")]
public string Label
Field Value
Remarks
Never used for a character's name. Names come from the character itself and are suppressed for anything the detection rule covers — a name attached to a throttled position would hand a modified client the one piece of information the throttling exists to withhold.
MarkerAnchor
Where the marker is drawn. Defaults to this transform.
[Tooltip("Optional transform the marker is drawn at. Uses this object when empty.")]
public Transform MarkerAnchor
Field Value
- Transform
Remarks
Overridable so a marker on a large object can sit at its entrance rather than at its pivot, which for a building is usually its corner.
Priority
Draw priority when markers overlap. Higher wins; ties fall back to the type ordinal.
[Tooltip("Draw priority when markers overlap. Higher draws on top.")]
public int Priority
Field Value
ShowOnMinimap
Whether the marker is drawn on the minimap.
[Tooltip("Draw this marker on the minimap.")]
public bool ShowOnMinimap
Field Value
ShowOnWorldMap
Whether the marker is drawn on the world map.
[Tooltip("Draw this marker on the world map.")]
public bool ShowOnWorldMap
Field Value
Tint
Tint multiplied into the icon.
[Tooltip("Tint multiplied into the icon.")]
public Color Tint
Field Value
- Color
Type
What this marker represents.
[Tooltip("What this marker represents. Drives the default icon, draw order and filter row.")]
public MapMarkerType Type
Field Value
Visibility
The rule deciding whether the local player may see this marker.
[Tooltip("Rule deciding whether the local player may see this marker.")]
public MapMarkerVisibility Visibility
Field Value
Remarks
Left at Always for world fixtures. A prefab that can be a player character should use Detection: the runtime promotes it to full fidelity for party and guild members by itself, so authoring the strict rule costs nothing and a prefab that is never revisited stays safe.
Properties
Character
The character this marker belongs to, when it is on one. Null for world fixtures.
public ICharacter Character { get; }
Property Value
Remarks
Resolved once, on enable, and used by the client to work out the live relationship
between the local player and this object. Cached rather than looked up per frame
because GetComponent against an interface walks every component on the
GameObject, and the map refreshes this for every marker in view.
FacingDegrees
The direction the marker's icon faces, in degrees clockwise from world north.
public float FacingDegrees { get; }
Property Value
Position
The world position the marker is drawn at.
public Vector3 Position { get; }
Property Value
- Vector3