Logo
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

NameTypeDescription
SelectionIReadOnlyList<MarqueeSelectable>Read-only selected items.
SelectionCountintNumber of selected items.
IsSelectingboolWhether a selection rectangle is being drawn.
IsDraggingboolWhether the selection is being dragged.

Fields

NameTypeDescription
hitTestHitTestOverlap or Contained hit testing.
allowModifiersboolEnables modifier-key selection.
bringToFrontboolDraws dragged items above the rest of the UI during the drag.
transferModeTransferModeRules for moving items between containers.
allowedTargetsMarqueeSelection[]Explicit destinations when using AllowedTargets.

Methods

NameParametersDescription
Select()MarqueeSelectable itemSelects a MarqueeSelectable.
Deselect()MarqueeSelectable itemDeselects an item.
ClearSelection()NoneDeselects everything.
SelectAll()NoneSelects all eligible items.
Cancel()NoneCancels the current gesture.
CanTransferTo()MarqueeSelection targetChecks whether a destination accepts transfer. Returns bool.

Events

NameTypeDescription
onSelectionChangedUnityEventSelection changed; read Selection for the result.
onDragStartedUnityEventGroup dragging started.
onDragEndedUnityEventGroup dragging ended.
OnTransferredAction<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

MarqueeSelectionExample.cs
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();
    }
}

On this page