Class UITKMerchant
UI Toolkit merchant panel. Receives the merchant template via a server broadcast and renders its items, abilities, and ability events as tabbed entry slots, plus a Sell tab listing the character's own inventory. Selecting an entry opens the transaction footer, where a quantity is chosen and the trade explicitly confirmed.
public class UITKMerchant : UITKCharacterControl
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourUITKMerchant
- 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
Why a footer rather than a click. Buying used to be a bare Ctrl+Left click on a row: one mis-aimed click spent money, and a double click spent it twice. There was no quantity at all, and no sell path of any kind. Every trade now goes through the footer, which names what is being traded, how many, and what it costs, and needs a second, deliberate press to commit.
Double-submit. Both directions hold a PendingReplyGuard and disable the confirm button while a request is outstanding. Without it a double click on Sell submits the same slot twice: the first sale empties the slot, and by the time the second arrives the slot may hold something else entirely — the item-loss vector. On the buy side the same double click simply spends twice.
Nothing here is authoritative. The quantity is clamped locally for the player's benefit and clamped again on the server, which recomputes the price from its own templates. The client never sends a price, and the totals shown here are display only.
Content is written after Show, and again after a tree rebuild. A
UIDocument re-clones its UXML on every enable, so anything written before
Show() is discarded. The merchant offer arrives in a broadcast, is
kept as plain data, and is rendered from OnAfterShow() and
OnAfterStarting() — both, because on a panel's very first open
hasStarted is still false and the re-initialisation path bails out before
OnAfterShow would help.
Methods
Hide(bool)
Hides the tooltip along with the panel.
public override void Hide(bool overrideIsAlwaysOpen)
Parameters
overrideIsAlwaysOpenbool
Remarks
Closing the merchant with Escape while the pointer sat over a row left the tooltip on screen for good: the row's PointerLeave never fires, because the element is not left — it is destroyed along with the rest of the tree when the document is disabled.
OnAfterShow()
Renders the merchant's offer into the tree the player is about to see.
protected override void OnAfterShow()
OnAfterStarting()
Renders the merchant's offer again after the visual tree has been rebuilt.
protected override void OnAfterStarting()
Remarks
Both hooks are needed. OnAfterShow alone does nothing on a panel's first open,
because the tree-replacement check bails out while hasStarted is still false;
OnAfterStarting alone misses every subsequent reopen.
OnClientSet()
Registers the merchant broadcast handlers when the client is set.
public override void OnClientSet()
OnClientUnset()
Unregisters the merchant broadcast handlers when the client is unset.
public override void OnClientUnset()
OnDestroying()
Clears all entry slots when the control is destroyed.
public override void OnDestroying()
OnPostSetCharacter()
Subscribes to inventory changes so the Sell tab tracks the character's bags.
public override void OnPostSetCharacter()
OnPreSetCharacter()
Drops the outgoing character's inventory subscription.
public override void OnPreSetCharacter()
Remarks
Overridden rather than left to OnPreUnsetCharacter() because
OnAfterStarting re-runs the Pre/Post pair on every visual tree rebuild and never
touches the Unset half. Subscribing in Post without a matching unsubscribe in Pre is
how a panel ends up with one extra handler per reopen.
OnPreUnsetCharacter()
Drops the inventory subscription before the character is cleared.
public override void OnPreUnsetCharacter()
OnStarting()
Queries the tab buttons, entry containers and transaction footer, and wires them up.
public override void OnStarting()
OnTick()
Drives the two request watchdogs and the coalesced sell-list rebuild.
protected override void OnTick()