Skip to content

SelectionDisplayUtility

Namespace: SideXP.Selection

public static class SelectionDisplayUtility

Utility functions for displaying selections on GUI.

Fields

MaxNamedObjectsCount

public const int MaxNamedObjectsCount = 3

The maximum number of object names used to name a selection.

MaxNameLength

public const int MaxNameLength = 40

The maximum length of a selection name, including Ellipsis if the name is truncated.

Ellipsis

public const string Ellipsis = "..."

The text appended to a truncated name.

Methods

GetNamedObjects(SelectionSnapshot)

public static List<ObjectRef> GetNamedObjects(SelectionSnapshot snapshot)

Gets the objects used to name and illustrate a given selection: the objects that are not temporary (assets and objects saved in a scene), or all the objects if they're all temporary.

Parameters

  • snapshot: The selection to name.

Returns

Returns the objects to use, in selection order.

GetMainObject(SelectionSnapshot)

public static ObjectRef GetMainObject(SelectionSnapshot snapshot)

Gets the object that represents a given selection, for example to display its icon.

Parameters

  • snapshot: The selection.

Returns

Returns the first of the objects returned by GetNamedObjects, or null if the selection is empty.

GetName(SelectionSnapshot)

public static string GetName(SelectionSnapshot snapshot)

Gets the display name of a given selection: the names of its first objects separated by commas, truncated by word if it's too long.

Parameters

  • snapshot: The selection to name.

Returns

Returns the display name, or an empty string if the selection is empty.

Remarks

Uses GetNamedObjects to choose the objects, with their names as they were when the selection was captured, at most MaxNamedObjectsCount of them, and truncated to MaxNameLength characters.

GetUnavailableObjectsMessage(SelectionSnapshot)

public static string GetUnavailableObjectsMessage(SelectionSnapshot snapshot)

Gets a message describing the objects of a given selection that can't be selected, grouped by the scene that must be loaded to select them.

Parameters

  • snapshot: The selection to check.

Returns

Returns the message, or an empty string if all the objects of the selection can be selected.

TruncateByWord(string, int)

public static string TruncateByWord(string text, int maxLength)

Truncates a given text at the end of the last whole word that fits, and appends Ellipsis to it.

Parameters

  • text: The text to truncate.
  • maxLength: The maximum length of the result, including Ellipsis.

Returns

Returns the text as is if it's not longer than the given length, or the truncated text. A single word longer than the available space is cut in the middle.