Class UITKContextMenu
A floating context menu that displays a dynamic list of action buttons at the mouse position. Used for right-click interactions on player targets (Inspect, Add Friend, Invite to Party, Trade).
public class UITKContextMenu : UITKControl
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourUITKContextMenu
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Remarks
Entries are plain Button elements built here rather than instantiated from a prefab
into a layout-group parent, so the panel has no scene dependencies that can go missing.
The entries a caller passes to Open(List<(string label, Action callback)>) are recorded rather than built on the spot. Enabling the document re-clones the UXML, and on the very first open the visual tree does not exist at all — so building at call time filled a tree that was either discarded a moment later or was never there. OnAfterShow() and OnAfterStarting() build them into whichever tree is actually live.
Placement goes through UITKScreenSpace: the pointer arrives in screen pixels with Y measured from the bottom, the panel is laid out in points with Y from the top, and a menu opened near an edge has to be flipped to the other side of the cursor rather than sliding back over it.
Properties
Layer
Draw order tier for this panel. See UITKPanelLayer.
protected override UITKPanelLayer Layer { get; }
Property Value
Methods
Hide(bool)
Hides the menu and drops its entries so stale callbacks cannot be invoked.
public override void Hide(bool overrideIsAlwaysOpen)
Parameters
overrideIsAlwaysOpenboolWhen true, the call is a no-op.
Remarks
The override is on Hide(bool). Hide() forwards here, but quit-to-login
calls Hide(false) directly — so an override on the parameterless form alone
left a menu's captured callbacks, which reference the character that has just gone
away, alive across a return to the login screen.
OnAfterShow()
Builds the recorded entries into the live menu element and positions it.
protected override void OnAfterShow()
OnAfterStarting()
Rebuilds the recorded entries after the visual tree was replaced.
protected override void OnAfterStarting()
OnDestroying()
Clears entries on teardown.
public override void OnDestroying()
OnStarting()
Resolves elements and wires the hover tracking used by the outside-click check.
public override void OnStarting()
OnTick()
Closes the context menu when clicking outside of it.
protected override void OnTick()
Open(List<(string label, Action callback)>)
Opens the context menu at the current mouse position with the specified entries.
public void Open(List<(string label, Action callback)> entries)