Unity-Technologies/UnityCsReference · error · InvalidOperationException

Cannot select range when not in multi select mode.

Error message

Cannot select range when not in multi select mode.

What it means

ReorderableList.SelectRange throws InvalidOperationException when the list was not created with multiSelect=true. Range selection requires multi-select mode (it maintains an anchor and extends the selection set), so a single-select list cannot honor it and rejects the call.

Source

Thrown at Editor/Mono/GUI/ReorderableList.cs:670

        {
            int insertionIndex = m_Selection.BinarySearch(index);
            if (insertionIndex < 0 || append == false && m_Selection.Count > 1)
            {
                if (!append)
                {
                    m_Selection.Clear();
                    m_Selection.Add(index);
                }
                else
                {
                    m_Selection.Insert(~insertionIndex, index);
                }
            }
        }

        public void SelectRange(int indexFrom, int indexTo)
        {
            if (!multiSelect) throw new InvalidOperationException("Cannot select range when not in multi select mode.");

            m_Selection.Clear();
            for (int i = Mathf.Min(indexFrom, indexTo); i <= Mathf.Max(indexFrom, indexTo); ++i)
            {
                m_Selection.Add(i);
            }
        }

        public bool IsSelected(int index)
        {
            return m_Selection.BinarySearch(index) >= 0;
        }

        public void Deselect(int index)
        {
            int foundIndex = m_Selection.BinarySearch(index);
            if (foundIndex >= 0)
            {

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Check list.multiSelect before calling SelectRange; fall back to single selection otherwise.
  2. Construct the list with multiSelect: true if range selection is required.
  3. Centralize selection logic in a helper that branches on multiSelect.

Example fix

// before
list.SelectRange(from, to);
// after
if (list.multiSelect) list.SelectRange(from, to);
else list.index = from;
Defensive patterns

Strategy: validation

Validate before calling

if (list.multiSelect)
    list.SelectRange(indexFrom, indexTo);
else
    list.index = indexFrom;

Prevention

When it happens

Trigger: Calling list.SelectRange(from, to) on a ReorderableList constructed without multiSelect, or after multiSelect was set to false; a generic list helper that calls SelectRange without checking the mode.

Common situations: Reusing a list instance whose multiSelect flag changed; sharing a helper across single- and multi-select lists; default-constructed lists (multiSelect defaults false).

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/a46744d4553c9520. Report an issue: GitHub.