SelectionSnapshot¶
Namespace:
SideXP.Selection
Saved state of a selection, which can be applied again later.
Constructors¶
SelectionSnapshot(IEnumerable<Object>, Object)¶
Creates a snapshot of the given selection.
Parameters
objects: The selected objects. Null entries and duplicates are ignored.activeObject: The active object of the selection. Ignored if it's not one of the selected objects.
Properties¶
Objects¶
The selected objects.
Count¶
The number of selected objects.
IsEmpty¶
Checks if this snapshot doesn't contain any object.
Active¶
The reference to the active object of the selection, or null if there's no active object.
Methods¶
FromCurrentSelection()¶
Creates a snapshot of the current selection in the editor.
Returns
Returns the created snapshot.
Resolve(Object)¶
Resolves the selected objects.
Parameters
activeObject: Outputs the active object, or null if there's no active object or if it can't be resolved.
Returns
Returns the selected objects that can be resolved.
Resolve()¶
Resolves the selected objects.
Returns
Returns the selected objects that can be resolved.
CanResolve()¶
Checks if at least one of the selected objects can be resolved.
Returns
Returns true if this snapshot can be applied.
Matches(IEnumerable<Object>)¶
Checks if the resolved objects of this snapshot are the given ones, regardless of their order. The active object is not compared.
Parameters
objects: The objects to compare. Null entries are ignored.
Returns
Returns true if the resolved objects are the same as the given ones.
Matches(SelectionSnapshot)¶
Checks if the resolved objects of this snapshot are the given ones, regardless of their order. The active object is not compared.
Parameters
other: The snapshot to compare.
Returns
Returns true if the resolved objects are the same as the given ones.
HasSameObjects(SelectionSnapshot)¶
Checks if this snapshot and the given one contain the same objects, regardless of their order. Unlike Matches, the objects that can't be resolved are compared too (using RefersToSameObject). The active object is not compared.
Parameters
other: The snapshot to compare.
Returns
Returns true if both snapshots contain the same objects.
Apply()¶
Selects the objects of this snapshot in the editor. Objects that can't be resolved are skipped.
Returns
Returns true if the selection has been applied, or false if none of the objects can be resolved.
Clean()¶
Removes the objects that don't exist anymore, or that can't be identified anymore (objects not saved in a scene that has been closed or reloaded, objects spawned in play mode once back to edit mode, ...). Objects saved in a scene that is not loaded are kept, since they can be resolved again once that scene is loaded.
Returns
Returns true if at least one object has been removed.
Remarks
The objects that don't have a stable id but are still resolved are refreshed, so they get one if possible (for example, an object selected in play mode that also exists in edit mode).
Clone()¶
Creates a copy of this snapshot, independent from the original one (cleaning or refreshing the copy doesn't affect the original).
Returns
Returns the created copy.
Refresh()¶
Captures again the identifiers of the objects that are still alive.
Returns
Returns true if the identifiers have been captured again.
Remarks
Does nothing in play mode, so the stable ids captured in edit mode are not lost.