Layout
Marquee Selection
Select and drag groups of UI objects with a selection rectangle
Overview
Marquee Selection supports box selection and group dragging inside a UI container. Each participating object has a Marquee Selectable component.
Usage
Add Marquee Selection to the selection surface and assign its content rectangle.
Add Marquee Selectable to each child that can be selected.
Choose whether overlapping the selection rectangle is enough, or the whole item must be contained.
Enable dragging and modifier keys if needed.
Tips
- Bring To Front draws dragged items above the rest of the UI while they move, so they stay visible over other items and containers, and outside scroll masks. The hierarchy and layout don't change. It's on by default.
- Use Movement Bounds to constrain group movement.
- For transfers, choose None, Any Container, or Allowed Targets, and configure the receiving container’s Accept Transfers setting.
- Each selectable can use a Graphic or Procedural Shape for its selected appearance.
Public API
Use MarqueeSelection in the Evo.UI namespace.
Properties
| Name | Type | Description |
|---|---|---|
Selection | IReadOnlyList<MarqueeSelectable> | Read-only selected items. |
SelectionCount | int | Number of selected items. |
IsSelecting | bool | Whether a selection rectangle is being drawn. |
IsDragging | bool | Whether the selection is being dragged. |
Fields
| Name | Type | Description |
|---|---|---|
hitTest | HitTest | Overlap or Contained hit testing. |
allowModifiers | bool | Enables modifier-key selection. |
bringToFront | bool | Draws dragged items above the rest of the UI during the drag. |
transferMode | TransferMode | Rules for moving items between containers. |
allowedTargets | MarqueeSelection[] | Explicit destinations when using AllowedTargets. |
Methods
| Name | Parameters | Description |
|---|---|---|
Select() | MarqueeSelectable item | Selects a MarqueeSelectable. |
Deselect() | MarqueeSelectable item | Deselects an item. |
ClearSelection() | None | Deselects everything. |
SelectAll() | None | Selects all eligible items. |
Cancel() | None | Cancels the current gesture. |
CanTransferTo() | MarqueeSelection target | Checks whether a destination accepts transfer. Returns bool. |
Events
| Name | Type | Description |
|---|---|---|
onSelectionChanged | UnityEvent | Selection changed; read Selection for the result. |
onDragStarted | UnityEvent | Group dragging started. |
onDragEnded | UnityEvent | Group dragging ended. |
OnTransferred | Action<MarqueeSelection> | C# notification carrying the destination container after transfer. |
Marquee Selectable
Use IsSelected, IsDragging, and Container to inspect an item. Select(), Deselect(), and SetInteractable(bool) control it. Its onSelected and onDeselected UnityEvents can update application-specific visuals.
Example
using UnityEngine;
using Evo.UI;
public class MarqueeSelectionExample : MonoBehaviour
{
[SerializeField] private MarqueeSelection target;
private void Start()
{
target.onSelectionChanged.AddListener(() =>
Debug.Log($"Selected {target.SelectionCount} items"));
target.ClearSelection();
}
}