Docsv3.20.2
Back to API Reference
Class

TextContextMenu

abstract
Inherits:MonoBehaviour

Context menu a field presents in Unity UI, from a prefab: its own (ContextMenuPrefab) or the project's (ContextMenuPrefab). UniTextContextMenu is the menu laid out from Unity UI objects; derive from this class for a menu of your own — radial, animated, anything.

Remarks

The field instantiates the prefab once per play session under the shared touch overlay, a screen-space canvas above every other measured in density-independent units, and every field presenting the same prefab shares that instance. The field calls Show each time the menu opens, whenever its entries change, and again to re-anchor a menu touch opened over a selection that moved; every call arrives on the main thread. Trigger tells the menu what opened it.

Derived Types(1)

Types that inherit from TextContextMenu.

public bool IsVisible{ get }

Whether the menu is shown.

public abstract void Show()

Shows entries at placement and records invoke as the single receiver of invoked entries until the next Show replaces it or Hide clears it — a menu shared across fields always reports to the field that showed it last. A disabled entry (IsEnabled) shows disabled or not at all and is never invoked; a menu left with nothing to show hides.

public abstract void Hide()

Hides the menu and clears the recorded receiver.

public virtual void HandleKey()

Receives a key pressed while the menu is shown for a mouse, a pen or the keyboard. The field keeps every key from its text until the menu closes and closes it on Escape itself; the menu moves through its entries with the rest or ignores them, as it does by default.