When Button Clicked
Fires when a player presses the interact button on the object, making it clickable in play mode.
Introduction
When Button Clicked is an event in the Interaction group of World Events. It fires when a player presses the interact button on the object, making the object clickable in play mode. Like every event, it does nothing by itself. It waits for the right moment, then runs all the actions connected to it. Use it when you want something to happen automatically as soon as a player presses the interact button on the object. This event belongs to the Interact component. Open the Interact component guide to see everything the component itself can do. The interact button is Uni's universal "use" action: this event fires on the single click, while devices that need a longer exchange use When Interaction Starts and When Interaction Ends instead. Pickups triggered by the same button flow into When Prop is Picked Up . When Button Clicked event in the World Editor Image The When Button Clicked event in the Script Editor. caption
Parameters
Player the player who pressed the interact button Parameter Description
How to Access
How to Access - When Button Clicked
How to Use
Select the object, press Propertie (the blue equalizer icon) in the bottom action menu, and scroll to the bottom of the properties panel. Press Add Component and pick the Interact component; its block stacks below the existing properties with the When Button Clicked event inside it. Press the + button below the event to add a script, then press Edit on that script to open the script editor and build the actions that should run when the event fires. Press Play and walk up to the object and press the interact button, then check that the actions run.
Example
When button is clicked by Player: Execute Player, Inventory.Remove All Items when-button-clicked-example.png Clears the clicked player inventory when the button is clicked. caption
Common Uses
Open doors, chests, or menus when the player interacts Start a conversation or show a message Pick up items and add them to an inventory
Tip
Test from the player's view, the interact hint only appears when the object is reachable and in range.