UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

177 lines (81 loc) 2.87 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [PlayerUI](./server.playerui.md) ## PlayerUI class The UI for a player. When to use: showing overlays, HUDs, menus, and custom UI for a specific player. Do NOT use for: world-level UI shared by all players; use scene UI systems instead. **Signature:** ```typescript export default class PlayerUI extends EventRouter ``` **Extends:** [EventRouter](./server.eventrouter.md) ## Remarks UI is driven by HTML, CSS, and JavaScript files in your `assets` folder. <h2>Events</h2> This class is an EventRouter, and instances of it emit events with payloads listed under `PlayerUIEventPayloads`<!-- -->. \*\*Category:\*\* Players The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `PlayerUI` class. ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [player](./server.playerui.player.md) </td><td> `readonly` </td><td> [Player](./server.player.md) </td><td> The player that the UI belongs to. \*\*Category:\*\* Players </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [append(htmlUri)](./server.playerui.append.md) </td><td> </td><td> Appends UI HTML to the player's existing client UI. Use for: incremental overlays (notifications, tooltips, modal layers). Do NOT use for: replacing the entire UI; use `PlayerUI.load`<!-- -->. </td></tr> <tr><td> [freezePointerLock(freeze)](./server.playerui.freezepointerlock.md) </td><td> </td><td> Freezes or unfreezes the player's pointer lock state. Use for: menus or cutscenes that should not alter pointer lock. </td></tr> <tr><td> [load(htmlUri)](./server.playerui.load.md) </td><td> </td><td> Loads client UI for the player, replacing any existing UI. Use for: switching to a new UI screen or resetting the UI. Do NOT use for: incremental overlays; use `PlayerUI.append`<!-- -->. </td></tr> <tr><td> [lockPointer(lock)](./server.playerui.lockpointer.md) </td><td> </td><td> Locks or unlocks the player's mouse pointer on desktop. Use for: controlling when mouse input is captured. Do NOT use for: mobile devices (pointer lock has no effect). </td></tr> <tr><td> [sendData(data)](./server.playerui.senddata.md) </td><td> </td><td> Sends data to the player's client UI. Use for: pushing state updates to your UI scripts. </td></tr> </tbody></table>