Table of Contents

Class UITKMapView

Namespace
FishMMO.Client
Assembly
FishMMO.Client.dll

The map itself: terrain image, fog of war, markers, and the chrome that sits over them. Used by both the minimap and the world map.

public class UITKMapView : VisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
Inheritance
CallbackEventHandler
Focusable
VisualElement
UITKMapView
Implements
IEventHandler
IResolvedStyle
ITransform
ITransitionAnimations
IExperimentalFeatures
IVisualElementScheduler
ICustomStyle
Inherited Members
VisualElement.disabledUssClassName
VisualElement.ReleaseResources()
VisualElement.Focus()
VisualElement.SendEvent(EventBase)
VisualElement.MarkDirtyRepaint()
VisualElement.IsMarkedForRepaint()
VisualElement.ContainsPoint(Vector2)
VisualElement.Overlaps(Rect)
VisualElement.ToString()
VisualElement.GetClasses()
VisualElement.GetClassNames()
VisualElement.ClearClassList()
VisualElement.AddToClassList(UniqueStyleString)
VisualElement.AddToClassList(UniqueStyleString, UniqueStyleString)
VisualElement.AddToClassList(params UniqueStyleString[])
VisualElement.RemoveFromClassList(UniqueStyleString)
VisualElement.ToggleInClassList(UniqueStyleString)
VisualElement.ClassListContains(UniqueStyleString)
VisualElement.FindAncestorUserData()
VisualElement.SetBinding(BindingId, Binding)
VisualElement.GetBinding(BindingId)
VisualElement.TryGetBinding(BindingId, out Binding)
VisualElement.GetBindingInfos()
VisualElement.HasBinding(BindingId)
VisualElement.ClearBinding(BindingId)
VisualElement.ClearBindings()
VisualElement.GetHierarchicalDataSourceContext()
VisualElement.GetDataSourceContext(BindingId)
VisualElement.TryGetDataSourceContext(BindingId, out DataSourceContext)
VisualElement.TryGetLastBindingToUIResult(in BindingId, out BindingResult)
VisualElement.TryGetLastBindingToSourceResult(in BindingId, out BindingResult)
VisualElement.Add(VisualElement)
VisualElement.Remove(VisualElement)
VisualElement.Clear()
VisualElement.Clear(VisualElementClearOptions)
VisualElement.IndexOf(VisualElement)
VisualElement.Children()
VisualElement.BringToFront()
VisualElement.SendToBack()
VisualElement.PlaceBehind(VisualElement)
VisualElement.PlaceInFront(VisualElement)
VisualElement.RemoveFromHierarchy()
VisualElement.GetFirstOfType<T>()
VisualElement.GetFirstAncestorOfType<T>()
VisualElement.Contains(VisualElement)
VisualElement.FindCommonAncestor(VisualElement)
VisualElement.ClearMeshModifiers()
VisualElement.RemoveMeshModifier(MeshModificationCallback)
VisualElement.userData
VisualElement.canGrabFocus
VisualElement.focusController
VisualElement.disablePlayModeTint
VisualElement.transform
VisualElement.scaledPixelsPerPoint
VisualElement.layout
VisualElement.contentRect
VisualElement.paddingRect
VisualElement.worldBound
VisualElement.localBound
VisualElement.worldTransform
VisualElement.hasActivePseudoState
VisualElement.hasInactivePseudoState
VisualElement.hasHoverPseudoState
VisualElement.hasCheckedPseudoState
VisualElement.hasEnabledPseudoState
VisualElement.hasDisabledPseudoState
VisualElement.hasFocusPseudoState
VisualElement.hasRootPseudoState
VisualElement.name
VisualElement.enabledSelf
VisualElement.viewDataKey
VisualElement.pickingMode
VisualElement.tooltip
VisualElement.usageHints
VisualElement.languageDirection
VisualElement.dataSourceType
VisualElement.resourcesReleased
VisualElement.enabledInHierarchy
VisualElement.visible
VisualElement.generateVisualContent
VisualElement.dataSource
VisualElement.dataSourcePath
VisualElement.experimental
VisualElement.hierarchy
VisualElement.cacheAsBitmap
VisualElement.parent
VisualElement.panel
VisualElement.contentContainer
VisualElement.visualTreeAssetSource
VisualElement.childCount
VisualElement.schedule
VisualElement.style
VisualElement.resolvedStyle
VisualElement.customStyle
VisualElement.styleSheets
Focusable.Blur()
Focusable.focusable
Focusable.tabIndex
Focusable.delegatesFocus
CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
CallbackEventHandler.RegisterCallbackOnce<TEventType>(EventCallback<TEventType>, TrickleDown)
CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
CallbackEventHandler.RegisterCallbackOnce<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, CallbackOptions)
CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TrickleDown)
CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, CallbackOptions)
CallbackEventHandler.UnregisterAllRemovableCallbacks()
CallbackEventHandler.HasTrickleDownHandlers()
CallbackEventHandler.HasBubbleUpHandlers()
CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
CallbackEventHandler.HandleEventBubbleUp(EventBase)
CallbackEventHandler.HandleEventTrickleDown(EventBase)
CallbackEventHandler.ExecuteDefaultAction(EventBase)
CallbackEventHandler.NotifyPropertyChanged(in BindingId)

Remarks

One element, two panels. The minimap and the world map differ in size, in where their image comes from and in what the player may do to them, and in nothing else. Everything below — the world-to-view mapping, the fog overlay, marker placement, edge clamping — is identical, and a second copy of it is how a note pinned on the world map ends up a few metres from where it shows on the minimap.

Four stacked layers, not one drawing. Background, terrain, fog and markers are separate child elements rather than one UnityEngine.UIElements.VisualElement.generateVisualContent pass on this element, because generated content on a parent draws behind all of its children — so the terrain would have had to be a child anyway, and then the fog could not have been drawn over it. Layers also let each one choose how it draws: see below.

Why the terrain layer has two ways to draw and the fog only one. The live minimap render texture is drawn as a plain background-image, because the camera has already rotated and framed exactly what should be on screen — there is no texture-coordinate work to do, and going through UI Toolkit's own path avoids the render-texture orientation difference between graphics APIs (a render target is stored bottom-up under OpenGL and top-down under D3D, Vulkan and Metal, so hand-written texture coordinates are upside down on half the platforms the client ships to). The baked world map and the fog are windows into a much larger image and need coordinates computed per corner, which a background image cannot express, so those are generated meshes — and both are ordinary Texture2Ds, where the orientation question does not arise.

Markers are real elements, not drawn into the mesh. They need labels, tooltips, hover states and clicks — everything UI Toolkit already does — and there are tens of them, not thousands. They are pooled rather than rebuilt, because a marker element recreated every refresh loses its hover state twice a second.

Constructors

UITKMapView()

Builds an empty view.

public UITKMapView()

Fields

MarkerClampedClass

USS class added to a marker that has been pinned to the frame edge.

public const string MarkerClampedClass = "map-marker--clamped"

Field Value

string

MarkerClass

USS class on each marker.

public const string MarkerClass = "map-marker"

Field Value

string

MarkerHeadingClass

Class of the arrow on a character's dot that shows which way it faces.

public const string MarkerHeadingClass = "map-marker__heading"

Field Value

string

MarkerIconClass

USS class on a marker's icon.

public const string MarkerIconClass = "map-marker__icon"

Field Value

string

MarkerLabelClass

USS class on a marker's label.

public const string MarkerLabelClass = "map-marker__label"

Field Value

string

MarkerLayerClass

USS class on the layer that markers live in.

public const string MarkerLayerClass = "map-view__markers"

Field Value

string

MarkerSelectedClass

Modifier on the waypoint marker chosen for fast travel (SelectedWaypointIndex).

public const string MarkerSelectedClass = "map-marker--selected"

Field Value

string

MarkerTypeClassPrefix

USS class prefix for the marker type modifier, completed with the type name.

public const string MarkerTypeClassPrefix = "map-marker--"

Field Value

string

ViewClass

USS class on the root of the view.

public const string ViewClass = "map-view-surface"

Field Value

string

Properties

Fog

The explored map drawn over the terrain, or null for no fog.

public FogOfWarMap Fog { get; set; }

Property Value

FogOfWarMap

FogColor

Colour of unexplored ground.

public Color FogColor { get; set; }

Property Value

Color

MapBackground

Colour drawn behind the map image.

public Color MapBackground { get; set; }

Property Value

Color

MapTexture

The terrain image drawn under everything. A live render texture, or a baked map.

public Texture MapTexture { get; set; }

Property Value

Texture

MapTextureIsViewAligned

Whether MapTexture is a live render of exactly this view.

public bool MapTextureIsViewAligned { get; set; }

Property Value

bool

MapTextureNorthDegrees

How far the baked image is turned from world north, in degrees clockwise: the map definition's NorthOffsetDegrees.

public float MapTextureNorthDegrees { get; set; }

Property Value

float

Remarks

The baker photographs a scene with its camera turned by the definition's north offset, so the image's up is world (sin, 0, cos) of that angle, not +Z. Sampled as though it were north-up, an offset map drew its terrain turned under markers that were not. The view itself stays north-up; only the sampling follows the photograph.

MapTextureRect

The world rectangle MapTexture covers.

public Rect MapTextureRect { get; set; }

Property Value

Rect

Remarks

Ignored when MapTextureIsViewAligned is set, because a live overhead render always covers exactly the view that produced it.

MapTint

Tint multiplied into the map image.

public Color MapTint { get; set; }

Property Value

Color

SelectedWaypointIndex

The waypoint chosen for fast travel, by its index in the scene; -1 for none. Its marker wears MarkerSelectedClass, so the one the travel button will take the player to stands out among the rest. Applied with the markers' visuals, on the next marker refresh.

public int SelectedWaypointIndex { get; set; }

Property Value

int

View

The window this view is showing.

public MapViewTransform View { get; set; }

Property Value

MapViewTransform

Methods

LocalToWorld(Vector2)

Converts a point inside this element into a world position.

public Vector3 LocalToWorld(Vector2 localPosition)

Parameters

localPosition Vector2

The point in the element's own coordinate space.

Returns

Vector3

The world position on the XZ plane.

RefreshSurface()

Redraws the terrain and fog layers without touching the markers.

public void RefreshSurface()

Remarks

Called after every overhead render. A render texture assigned as a background image does not by itself mark anything dirty, so a minimap between marker refreshes would show the last frame UI Toolkit happened to repaint rather than the one just rendered.

RelayoutMarkers()

Re-places the markers already collected, for the current View.

public void RelayoutMarkers()

Remarks

Split from SetMarkers(List<MapMarkerSnapshot>) because the two costs are wildly different and want wildly different rates. Collecting the markers walks the whole registry, resolves a relationship per marker and applies the visibility rules; placing them writes two style values per element. Collecting ten times a second is plenty — a creature crosses about two pixels of a minimap in that time — but the view itself moves every single frame with the player, so placing at the collection rate leaves every marker pinned to where the map used to be for a tenth of a second, which reads as the terrain sliding out from under the icons.

ReleaseMarkers()

Releases the marker elements back to the pool.

public void ReleaseMarkers()

Remarks

Called when a panel's visual tree is rebuilt. UI Toolkit hands a document a fresh root on every enable, so a view holding elements from the previous tree would keep adding them to a parent nobody draws.

SetMarkers(List<MapMarkerSnapshot>)

Replaces what the view draws and lays it out again.

public void SetMarkers(List<MapMarkerSnapshot> markers)

Parameters

markers List<MapMarkerSnapshot>

The markers to draw. Copied, not retained.

Remarks

Copied because the caller reuses its list every refresh; holding the caller's list would mean the view's contents changed underneath it between a refresh and the layout pass that acts on it.

WorldToLocal(Vector3)

Converts a world position into a point inside this element.

public Vector2 WorldToLocal(Vector3 worldPosition)

Parameters

worldPosition Vector3

The world position.

Returns

Vector2

The point in the element's own coordinate space.

WorldToTextureUV(Rect, Vector3, float)

Normalises a world position into a texture's coordinate space.

public static Vector2 WorldToTextureUV(Rect worldRect, Vector3 worldPosition, float northDegrees = 0)

Parameters

worldRect Rect

The world rectangle the texture covers.

worldPosition Vector3

The world position.

northDegrees float

How far the texture's up is turned clockwise from world +Z.

Returns

Vector2

Texture coordinates, not clamped.

Remarks

A turned texture is the bake camera's frame: centred on the rectangle, with the same width and height, its right along (cos, -sin) and its up along (sin, cos) in world XZ. At zero this is exactly the axis-aligned mapping.

Events

OnMapClicked

Raised when the player clicks the map without dragging it, with the world position they clicked and the marker nearest to it, when one was close enough to count.

public event Action<Vector3, MapMarkerSnapshot?> OnMapClicked

Event Type

Action<Vector3, MapMarkerSnapshot?>

OnMapScrolled

Raised when the player scrolls over the map, with the scroll delta.

public event Action<float> OnMapScrolled

Event Type

Action<float>