Selection reference
The components that select units with the pointer and draw markers under them, the marker styles, and the selection API. For how to use it, see Selection.
VtUnitSelection
Component. Add it with Add Component → Vantage → Selection → VtUnitSelection.
Selects units with the pointer for the local player. A Select press (left-click by default) on a unit selects it, with Shift it adds or removes it, a drag draws a box that selects the units inside, a double-click selects every unit of the same kind on screen, and a press on the ground or the clear key clears the selection. Command presses stay with VtTopDownClickInput and VtOrderInput.
Inspector fields
Side
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Viewer Faction (viewerFaction) |
VtFaction | Player |
The faction relations and box filters are measured from when this object has no VtUnit, such as an RTS commander. |
Clicking
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Unit Mask (unitMask) |
LayerMask |
Everything | Layers the click and hover raycast considers for units. | |
Ray Distance (rayDistance) |
float |
500 | ≥ 1 | Max raycast distance, in world units. |
Clear On Ground Click (clearOnGroundClick) |
bool |
On | A Select press that hits no unit clears the selection. | |
Select On Attack (selectOnAttack) |
bool |
On | An attack command selects its target, unless several units are selected. | |
Double Click Selects Same Kind (doubleClickSelectsSameKind) |
bool |
On | A double-click on a unit selects every unit with the same unit definition on screen. | |
Double Click Seconds (doubleClickSeconds) |
float |
0.3 | ≥ 0.05 | Seconds between two clicks on the same unit that count as a double-click. |
Select Action (selectAction) |
InputActionReference |
None | Selects and draws the box. Empty uses Select from the Vantage input actions, the left mouse button by default. | |
Command Action (commandAction) |
InputActionReference |
None | The command button, read only to tell whether it shares a button with Select. Empty uses Command, the right mouse button by default. | |
Clear Action (clearAction) |
InputActionReference |
None | Clears the selection. Empty uses Cancel from the Vantage input actions, Esc by default. | |
Additive Action (additiveAction) |
InputActionReference |
None | Held to add to the selection instead of replacing it. Empty uses Additive Modifier, Shift by default. |
Box
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Box Selection (boxSelection) |
bool |
On | Dragging with Select held draws a box that selects the units inside it. | |
Drag Threshold (dragThreshold) |
float |
6 | ≥ 0 | Pixels the pointer must move while pressed before the press becomes a box. |
Box Filter (boxFilter) |
VtBoxSelectionFilter | PreferOwnFaction |
Which units a box keeps when it covers several sides. | |
Draw Box (drawBox) |
bool |
On | Draw the box on screen. Turn off to draw your own from IsBoxSelecting and BoxScreenRect. | |
Box Fill Color (boxFillColor) |
Color |
#59BFFF1F |
Fill colour of the drawn box. | |
Box Border Color (boxBorderColor) |
Color |
#59BFFFD9 |
Border colour of the drawn box. |
Limits
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Max Selected (maxSelected) |
int |
0 | ≥ 0 | Most units selected at once. 0 = no limit. |
Scripting API
| Member | Description |
|---|---|
IReadOnlyList<VtUnit> Selected { get; } |
The selected units, primary first. |
VtUnit Primary { get; } |
The primary selected unit, or null. |
int Count { get; } |
Number of selected units. |
VtUnit Hovered { get; } |
The selectable unit under the pointer, or null. Null while a box is drawn. |
bool IsBoxSelecting { get; } |
True while Select is held and the pointer has moved far enough to draw a box. |
Rect BoxScreenRect { get; } |
The box in screen pixels, origin at the bottom left. Empty when no box is drawn. |
VtFaction ViewerFaction { get; } |
The faction relations and box filters are measured from: the unit on this object, or Viewer Faction without one. |
bool ClearOnGroundClick { get; set; } |
A Select press that hits no unit clears the selection. |
bool SelectOnAttack { get; set; } |
An attack command selects its target, unless several units are selected. |
bool BoxSelection { get; set; } |
Dragging draws a box that selects the units inside it. |
VtBoxSelectionFilter BoxFilter { get; set; } |
Which units a box keeps when it covers several sides. |
int MaxSelected { get; set; } |
Most units selected at once. 0 = no limit. |
Func<Vector2, VtUnit> UnitAtScreenPoint { get; set; } |
Finds the unit at a screen position. Null uses a raycast from the main camera on Unit Mask. |
Func<Vector3, Vector3> WorldToScreen { get; set; } |
Maps a world position to screen pixels with the depth in z. Null uses the main camera. |
Func<Rect> ScreenRect { get; set; } |
The visible screen area in pixels, for double-click selection. Null uses the whole screen. |
Func<IEnumerable<VtUnit>> Candidates { get; set; } |
The units boxes and double-clicks consider. Null uses every registered unit. |
event Action OnSelectionChanged |
Fires after the selection changed. |
event Action<VtUnit> OnHoverChanged |
Fires when the hovered unit changed, with the new unit or null. |
bool IsSelected(VtUnit unit) |
True when unit is selected. |
void Select(VtUnit unit) |
Select only unit. Null or a unit that cannot be selected clears the selection. |
void SelectMany(IEnumerable<VtUnit> units) |
Replace the selection with the selectable units in units. |
void Add(VtUnit unit) |
Add unit to the selection. |
void Remove(VtUnit unit) |
Remove unit from the selection. |
void Toggle(VtUnit unit) |
Add unit, or remove it when it is already selected. |
void Clear() |
Deselect every unit. |
void SelectSameKindOnScreen(VtUnit unit, bool additive = false) |
Select every living unit with the same unit definition as unit that is on screen, with unit as the primary. With additive they are added. |
bool ClaimsSharedPress(Vector2 screenPosition) |
True when a press at screenPosition that is both Select and Command belongs to the selection: the pointer is on a unit that can be selected and that the viewer cannot attack on command. Every other shared press belongs to the command input. |
bool IsSharedPressThisFrame() |
True when Select and Command were both pressed this frame, as happens when they share a button. |
void NotifyAttackOrder(VtUnit target) |
Tell the selection an attack command was given. Selects target when SelectOnAttack is on and at most one unit is selected. |
void PointerDown(Vector2 screenPosition) |
Select went down at screenPosition. Ignored while a ground ability is aimed. |
void PointerMove(Vector2 screenPosition) |
The pointer is at screenPosition. Updates the hover and turns a press into a box once it moved past the drag threshold. |
void PointerUp(Vector2 screenPosition, bool additive, double time) |
Select came up at screenPosition. Finishes a box or a click. additive is true while Shift is held; time is in seconds and detects double-clicks. |
VtSelectionIndicator
Component. Add it with Add Component → Vantage → Selection → VtSelectionIndicator. Adds VtUnitSelection automatically.
Draws a marker under every unit the sibling VtUnitSelection has selected, and under the hovered unit. Markers take the colour of the unit relation and the size of the unit. The look comes from a VtSelectionStyle: pick a package preset, make a ring style of your own, point a prefab style at any prefab, or subclass the style.
Inspector fields
Look
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Style (style) |
VtSelectionStyle | None | Style for selected units. Empty = a plain thin ring. | |
Hover Style (hoverStyle) |
VtSelectionStyle | None | Style for the hovered unit. Empty = the selected style. | |
Show Hover (showHover) |
bool |
On | Show a marker under the unit the pointer is over. |
Colours
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Friendly Color (friendlyColor) |
Color |
#59F273F2 |
Units of the selecting side. | |
Hostile Color (hostileColor) |
Color |
#FF5242F2 |
Units that fight the selecting side. | |
Neutral Color (neutralColor) |
Color |
#FFD94CF2 |
Every other unit. | |
Hover Alpha (hoverAlpha) |
float |
0.45 | 0 to 1 | Alpha multiplier for the marker of a hovered unit that is not selected. |
Size
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Radius Padding (radiusPadding) |
float |
0.15 | ≥ 0 | World units added to the unit radius. |
Scripting API
| Member | Description |
|---|---|
VtSelectionStyle Style { get; set; } |
Style for selected units. Null = a plain thin ring. Changing it rebuilds the markers. |
VtSelectionStyle HoverStyle { get; set; } |
Style for the hovered unit. Null = Style. |
bool ShowHover { get; set; } |
Show a marker under the hovered unit. |
float HoverAlpha { get; set; } |
Alpha multiplier for the marker of a hovered unit that is not selected. |
float RadiusPadding { get; set; } |
World units added to the unit radius. |
int MarkerCount { get; } |
Number of markers shown, selected and hovered. |
VtSelectionMarker MarkerFor(VtUnit unit) |
The marker shown for unit, or null. |
Color ColorFor(VtSelectionRelation relation) |
The colour for relation. |
static float ResolveRadius(VtUnit unit, float padding) |
The marker radius for unit: the unit definition Selection Radius when set, otherwise the radius of its character controller or collider, scaled, plus padding. |
void Refresh(float deltaTime) |
Create, move and remove markers to match the selection. Runs every frame in LateUpdate; call it yourself to drive the indicator from elsewhere. |
void ClearMarkers() |
Destroy every marker. They are created again on the next Refresh. |
VtRingSelectionMarker
Component. Add it with Add Component → Vantage → Selection → VtRingSelectionMarker. Inherits VtSelectionMarker.
The marker a VtRingSelectionStyle creates: a generated ring mesh that follows its unit, rebuilt when the radius changes and tinted through a material property block.
Scripting API
| Member | Description |
|---|---|
Mesh Mesh { get; } |
The generated ring mesh. |
void Configure(VtRingSelectionStyle ringStyle) |
Take shape and material from ringStyle. |
override void Apply(in VtSelectionMarkerState state, float deltaTime) |
Move the ring to the unit, rebuild it when the radius changed, turn it and tint it. |
VtPrefabSelectionMarker
Component. Add it with Add Component → Vantage → Selection → VtPrefabSelectionMarker. Inherits VtSelectionMarker.
The marker a VtPrefabSelectionStyle adds to a prefab without its own VtSelectionMarker: follows the unit, scales by the radius, turns, and tints every renderer through a material property block.
Scripting API
| Member | Description |
|---|---|
void Configure(VtPrefabSelectionStyle prefabStyle) |
Take placement and tint settings from prefabStyle. |
override void Apply(in VtSelectionMarkerState state, float deltaTime) |
Move the marker to the unit, scale it by the radius when the style asks for it, turn it and tint it. |
VtRingSelectionStyle
Asset. Create it with Create → Vantage → Selection → Ring Style. Inherits VtSelectionStyle.
A selection style that draws a generated ring: thin or wide, hard or soft edged, solid or dashed, still or turning. The package presets ThinRing, SoftRing, Brackets and SpinningDashes are assets of this type.
Inspector fields
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Material (material) |
Material |
None | Material for the ring. Empty = a transparent unlit material made at runtime. Softness needs a shader that multiplies vertex colour, such as URP Particles Unlit. | |
Thickness (thickness) |
float |
0.08 | ≥ 0.005 | Width of the ring in world units, measured inward from the marker radius. |
Softness (softness) |
float |
0 | 0 to 1 | Share of the width that fades out at both edges. 0 = hard edges. |
Dashes (dashes) |
int |
0 | ≥ 0 | Number of dashes. 0 = a solid ring. 4 with a low Dash Fill draws corner brackets. |
Dash Fill (dashFill) |
float |
0.5 | 0.02 to 1 | Share of each dash slot that is drawn. |
Spin Degrees Per Second (spinDegreesPerSecond) |
float |
0 | Degrees per second the ring turns. 0 = still. | |
Radius Scale (radiusScale) |
float |
1 | ≥ 0.1 | Multiplies the marker radius, for a ring further out or closer in. |
Height Offset (heightOffset) |
float |
0.04 | ≥ 0 | Height above the unit position, so the ring does not sink into the ground. |
Segments (segments) |
int |
64 | 8 to 256 | Segments in a full circle. More is smoother. |
Scripting API
| Member | Description |
|---|---|
override VtSelectionMarker CreateMarker() |
Create a ring marker with this style’s shape and material. |
VtPrefabSelectionStyle
Asset. Create it with Create → Vantage → Selection → Prefab Style. Inherits VtSelectionStyle.
A selection style that uses any prefab as the marker: a decal projector, a textured quad, a mesh or particles, authored for a radius of 1. The marker is placed at the unit, scaled by the radius and tinted with the relation colour. When the prefab carries its own VtSelectionMarker, that component drives it instead.
Inspector fields
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Prefab (prefab) |
GameObject |
None | The marker prefab, authored for a radius of 1. A VtSelectionMarker component on it takes over placing, sizing and colouring. | |
Scale With Radius (scaleWithRadius) |
bool |
On | Scale the prefab by the marker radius. | |
Tint (tint) |
bool |
On | Tint the prefab renderers with the relation colour through _BaseColor and _Color. | |
Spin Degrees Per Second (spinDegreesPerSecond) |
float |
0 | Degrees per second the marker turns. 0 = still. | |
Height Offset (heightOffset) |
float |
0.04 | ≥ 0 | Height above the unit position. |
Scripting API
| Member | Description |
|---|---|
override VtSelectionMarker CreateMarker() |
Instantiate the prefab as a marker. Uses the prefab’s own VtSelectionMarker when it has one. Returns null when no prefab is set. |
VtSelectionStyle
Abstract asset base. Shipped subclasses: VtPrefabSelectionStyle, VtRingSelectionStyle.
The look of selection markers. The package ships VtRingSelectionStyle, with presets, and VtPrefabSelectionStyle for any prefab. A new look is a subclass that returns its own VtSelectionMarker.
Scripting API
| Member | Description |
|---|---|
abstract VtSelectionMarker CreateMarker() |
Create one marker. VtSelectionIndicator owns it and destroys it when its unit is no longer shown. Return null to show nothing. |
VtSelectionMarker
Abstract component base. Shipped subclasses: VtPrefabSelectionMarker, VtRingSelectionMarker.
One marker under a selected or hovered unit. A VtSelectionStyle creates it and VtSelectionIndicator calls Apply every frame while the unit is shown, then destroys it. Subclass it for a custom look, either from a style of your own or as a component on the prefab of a VtPrefabSelectionStyle.
Scripting API
| Member | Description |
|---|---|
abstract void Apply(in VtSelectionMarkerState state, float deltaTime) |
Show state: place, size and colour the marker. |
VtSelectionMarkerState
Struct.
What a selection marker shows this frame. Passed to VtSelectionMarker.Apply.
Scripting API
| Member | Description |
|---|---|
VtUnit Unit |
The unit the marker belongs to. |
Vector3 Position |
The unit position in world space, at its feet. |
float Radius |
Marker radius in world units: the unit radius plus the indicator padding. |
Color Color |
Colour for the unit relation, faded for a hovered unit that is not selected. |
VtSelectionRelation Relation |
How the unit relates to the selecting side. |
bool IsSelected |
True when the unit is selected. |
bool IsPrimary |
True when the unit is the primary selection. |
bool IsHovered |
True when the pointer is over the unit. |
VtSelectionSet
Class.
An ordered set of selected units. The first unit is the primary selection: the one a unit frame shows and single-target abilities fall back to. Pure C#, so any input scheme can keep one and tests need no scene. Every call that changes the set raises OnChanged once; calls that change nothing raise nothing.
Scripting API
| Member | Description |
|---|---|
IReadOnlyList<VtUnit> Units { get; } |
The selected units, primary first. Can hold destroyed units until PruneDestroyed runs. |
int Count { get; } |
Number of selected units. |
VtUnit Primary { get; } |
The primary selected unit, or null when nothing is selected. |
int MaxCount { get; set; } |
Most units the set holds. 0 = no limit. Lowering it drops units from the end. |
event Action OnChanged |
Fires after the selection changed. |
bool Contains(VtUnit unit) |
True when unit is selected. |
void SelectOnly(VtUnit unit) |
Select only unit. Null clears the selection. |
void Set(IEnumerable<VtUnit> selection) |
Replace the selection with selection, in order, without nulls or duplicates. |
void Add(VtUnit unit) |
Add unit after the units already selected. |
void AddRange(IEnumerable<VtUnit> selection) |
Add every unit in selection after the units already selected. |
void Remove(VtUnit unit) |
Remove unit. The next unit becomes primary when the primary is removed. |
void Toggle(VtUnit unit) |
Remove unit if it is selected, otherwise add it. |
void Clear() |
Deselect every unit. |
bool PruneDestroyed() |
Drop destroyed units. Returns true when any were dropped. |
VtSelectionRules
Static class.
The rules selection runs on, as pure functions: which units can be selected, how a unit relates to the selecting side, and which units a screen rectangle picks.
Scripting API
| Member | Description |
|---|---|
static VtSelectionRelation Relation(VtFaction viewer, VtUnit unit) |
How unit relates to a selecting side of faction viewer. |
static bool CanSelect(VtUnit unit, bool allowDead) |
True when unit exists, is active, and its definition allows selection. Dead units count only when allowDead is true. |
static void UnitsInScreenRect(IEnumerable<VtUnit> candidates, Rect screenRect, Func<Vector3, Vector3> worldToScreen, VtFaction viewer, VtBoxSelectionFilter filter, List<VtUnit> results) |
Fill results with the selectable, living units whose position falls inside screenRect, then narrow them with filter. worldToScreen maps a world position to screen pixels with the depth in z; units at or behind the camera are skipped. |
static void ApplyFilter(List<VtUnit> units, VtFaction viewer, VtBoxSelectionFilter filter) |
Narrow units in place with filter, keeping their order. |
Enums
VtFaction
Team or allegiance of a VtUnit. Units of different factions fight each other unless either is Neutral; AI targeting, splash damage and projectiles all respect it.
| Value | Description |
|---|---|
Neutral |
Unaffiliated or ambient — not targeted, not hostile. |
Player |
The local player and their summons / pets. |
Enemy |
Scripted hostile units (waves, bosses). |
Wildlife |
Passive NPCs (deer, rabbits) — flee when attacked, don’t aggro. |
VtBoxSelectionFilter
Which units a box selection keeps when the box covers units of different sides.
| Value | Description |
|---|---|
PreferOwnFaction |
Units of the selecting side if the box holds any, otherwise hostile units, otherwise the rest. |
OwnFactionOnly |
Only units of the selecting side. |
Everything |
Every selectable unit in the box. |
VtSelectionRelation
How a selected or hovered unit relates to the selecting side. Marker colours follow it.
| Value | Description |
|---|---|
Friendly |
The same faction as the selecting side. |
Hostile |
A faction that fights the selecting side. |
Neutral |
Neither: neutral units, or factions that do not fight the selecting side. |