Class UITKContainer
UI Toolkit implementation of the world container panel — chests, crates, wardrobes.
Binds to UIContainer.uxml / UIContainer.uss.
public class UITKContainer : UITKCharacterControl
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourUITKContainer
- 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.MemberwiseClone()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
A pure view of server state, for the same reason the corpse loot panel is one: a container in the world is not private, so the item a player is looking at may already have been taken by somebody else standing at the same chest. Nothing here removes a row — a click sends a request naming a slot index, the row is marked as waiting, and what changes the display is the server sending the container's contents back.
ContainerOpenBroadcast serves as both the open message and the refresh, so there is
exactly one code path for "here is what is in the box". A client that missed an update
converges on the next one rather than compounding the error.
Properties
OpensInventoryOnShow
True for a panel that should bring the inventory up alongside itself when it opens.
protected override bool OpensInventoryOnShow { get; }
Property Value
Remarks
Interaction panels — shops, the bank — are where the player is about to move items, and opening one without the inventory meant a second key press before anything could be dragged. Each such panel exposes an inspector toggle and overrides this to return it; the default is off so HUD elements and dialogs stay out of it. (Issue #208.)
Methods
Hide(bool)
Hides the panel unless overrideIsAlwaysOpen is true.
public override void Hide(bool overrideIsAlwaysOpen)
Parameters
overrideIsAlwaysOpenboolWhen true, the call is a no-op.
OnAfterShow()
Fills the panel on every show, including the very first one.
protected override void OnAfterShow()
Remarks
When hiding disabled the document, every show re-cloned the UXML and discarded anything
written before Show(). This panel is always opened by a server broadcast rather
than at startup, and OnAfterStarting runs only at startup and on a genuine tree
replacement, so it alone is not enough. Both hooks do the work and both are idempotent.
OnAfterStarting()
Re-applies the character once the visual tree exists.
protected override void OnAfterStarting()
Remarks
World entry calls SetCharacter(IPlayerCharacter) for every control at once, and
a control's visual tree can come up after its Awake (and, when hiding disabled the
document, a hidden control had none until something showed it) — so
OnPostSetCharacter() can run before OnStarting has cached any
elements. Overrides that write into those elements would then dereference null, and
even a null-safe one would leave the panel showing nothing, because the only call
that had data already happened. Running it again here is what makes the two orders
equivalent.
OnClientSet()
Called when a Client is injected via SetClient(Client). Override to subscribe to client events.
public override void OnClientSet()
OnClientUnset()
Called when the Client is cleared via SetClient(Client). Override to unsubscribe from client events.
public override void OnClientUnset()
OnDestroying()
Runs the character-unset path when this control is destroyed.
public override void OnDestroying()
Remarks
The unset path, not a bare null assignment. Panels drop their subscriptions to the character's events in OnPreUnsetCharacter(), and clearing the field behind their back skipped every one of them. The character outlives the panel — it is the panel that is destroyed on a scene change, not the character — so those still-live events kept invoking handlers on a destroyed MonoBehaviour: the panel is leaked by its own subscriptions, and the first handler to touch a Unity object throws MissingReferenceException from inside the character's event dispatch.
OnStarting()
Called once the control's visual tree is available. Override to perform one-time initialisation against Root.
public override void OnStarting()
Remarks
Guaranteed to see a populated Root. Runs once, as soon as the tree exists: for a panel that starts hidden that is scene load, not its first open, so it must not assume a character, a client or a visible panel. Per-open work belongs in OnAfterShow(). Runs again only if the document's tree is genuinely replaced.
OnTick()
Per-frame hook for controls that need one.
protected override void OnTick()