Skip to content

SelectionHistory

Namespace: SideXP.Selection

public static class SelectionHistory

Tracks the selection changes in the editor, and allows navigating through the previous selections.

Remarks

Empty selections are not recorded. A selection is recorded only once it has remained unchanged for CommitDelay, so interactions that change the selection many times in a row (like rectangle selection in the Scene view) produce a single entry. The folders browsed from the folder tree of the Project window (two columns layout) are recorded the same way, as if they were selected (see ShouldRecordBrowsedFolders).

Properties

Entries

public static IReadOnlyList<SelectionSnapshot> Entries

Inherited documentation.

CurrentIndex

public static int CurrentIndex

Inherited documentation.

Current

public static SelectionSnapshot Current

The current entry, or null if the history is empty.

CanGoBack

public static bool CanGoBack

Checks if there's a previous entry that can be selected.

CanGoForward

public static bool CanGoForward

Checks if there's a next entry that can be selected.

Events

OnChanged

public static Action OnChanged

Called when the history has changed (new entry, navigation, ...).

Methods

Back(int)

public static bool Back(int count = 1)

Selects a previous entry of the history. Entries that can't be resolved are skipped.

Parameters

  • count: The number of entries to go back by. If there are fewer previous entries, selects the oldest one.

Returns

Returns true if a previous entry has been selected.

Forward(int)

public static bool Forward(int count = 1)

Selects a next entry of the history. Entries that can't be resolved are skipped.

Parameters

  • count: The number of entries to go forward by. If there are fewer next entries, selects the most recent one.

Returns

Returns true if a next entry has been selected.

GoTo(int)

public static bool GoTo(int index)

Selects the entry at the given index of the history.

Parameters

  • index: The index of the entry to select.

Returns

Returns true if the entry has been selected, or false if the index is out of range or the entry can't be resolved.

Remarks

If the current selection has not been recorded yet, it's discarded, so the given index still targets the expected entry. The objects of the entry that can't be resolved are skipped, and a warning is logged to list them.

Clear()

public static void Clear()

Removes all the entries of the history, and records the current selection as the first entry.

Clean()

public static bool Clean()

Removes the objects that don't exist anymore from the entries, and the entries that become empty. If the current entry is removed, the previous remaining entry becomes the current one.

Returns

Returns true if at least one object or entry has been removed.

RefreshReferences()

public static void RefreshReferences()

Captures again the identifiers of the objects that are still alive in all the entries.

Flush()

public static void Flush()

Records the current selection now if it has changed, instead of waiting for CommitDelay.