Back to API Reference
Class

UniTextContextMenu

sealed
Inherits:MonoBehaviour

Text context menu you build yourself: lay out and style the panel, buttons, and toggles in the scene however you like, then list the ContextMenuItem bindings here — each maps one of your controls to a command. PrefabTextContextMenu drives it with the applicable capabilities, and standard commands route back to the presenter it passed. One menu is shareable across many fields — actions always reach the field that last showed it. The component only wires control events, shows / hides controls per applicability, positions the panel, and dismisses on an outside click — it draws nothing itself. Prefabs assigned to PrefabTextContextMenu use density-independent layout units.

Remarks

Visibility is driven through a CanvasGroup, never by toggling the GameObject active: the panel stays active so a sibling FocusGuard keeps the editor focused while the user presses a control. Add the guard to this object to preserve focus during interaction.
public bool IsVisible{ get }

Whether the menu is currently shown.

public void Show()

Shows the menu at screenPosition, hiding the controls whose item is not applicable (or has no control assigned), and records presenter as the single receiver of invoked actions until the next Show / Hide. No-op (hides) when no item applies.

public void Hide()

Hides the menu and clears the recorded presenter.

public void RequestAction()

Routes the invoked command to the presenter recorded by the last Show — how command items reach it.