UIInstance - Paradigm-MP/oof GitHub Wiki
The UIInstance
class is a client-side class used to store information about a specific instance of UI. For example, your game might have a scoreboard, and you might want to display it using HTML, CSS, and JS. You'll have one UIInstance
for your scoreboard so you can easily transfer data to and from it and manipulate it.
Note: only the UI instance on top will receive mouse clicks. To receive mouse clicks in other UI instances, consider restricting the size of the UI instance using the css
argument of UI:Create
.
UI:Create
To create a new UIInstance, use UIInstance:CallEvent(event_name, data)
- Calls an event on a specific UI instance.
- The UI instance can listen for the event with
OOF.Subscribe
. event_name
(string): name of the event that you want to calldata
(table): table of data you want to send with the event
UIInstance:Subscribe(event_name, callback)
- Subscribes to an event called from the Javascript portion of the UI instance, meaning that when the JS code calls
OOF.CallEvent(event_name, data)
, it will be received here. - The UI instance can call the event with
OOF.CallEvent
. event_name
(string): name of the event you want to subscribe tocallback
(function): function to be called when the event name is called from the UI
UIInstance:Hide()
- Hides this UI instance.
UIInstance:Show()
- Shows this UI instance.
UIInstance:GetVisible()
- Returns whether or not this UI instance is visible or not.
UIInstance:BringToFront()
- Brings this UI instance to the front of all other UI instances. Good for when you want something to display on top, like chat or a scoreboard.
UIInstance:SendToBack()
- Sends this UI instance to the back behind all other UI instances.
UIInstance:Remove()
- Removes this UI instance entirely. It no longer exists.