new UISystemPlugin(context)uiSystem.js:61Create the global UI system object
contextCanvasRenderingContext2D|OffscreenCanvasRenderingContext2D optional
// create the ui plugin object
new UISystemPlugin;UI System Global Object
new UISystemPlugin(context)uiSystem.js:61Create the global UI system object
context CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D optional// create the ui plugin object
new UISystemPlugin;activateOnPress : booleanuiSystem.js:79Activate when mouse is pressed down instead of clicked
activeObject : UIObject|undefineduiSystem.js:149Object user is currently interacting with
confirmDialog : UIObject|undefineduiSystem.js:161Current confirm menu being shown
defaultButtonColor : ColoruiSystem.js:87Default button color for UI elements
defaultColor : ColoruiSystem.js:81Default fill color for UI elements
defaultCornerRadius : numberuiSystem.js:98Default rounded rect corner radius for UI elements
defaultDisabledColor : ColoruiSystem.js:91Default color for disabled UI elements
defaultFont : stringuiSystem.js:102Default font for UI elements
defaultGradientColor : Color|undefineduiSystem.js:94Uses a gradient fill combined with color
defaultHandleSlice : TileSlice|undefineduiSystem.js:124Style to draw slider handles with, undefined for the slider's own slice
defaultHoverColor : ColoruiSystem.js:89Default hover color for UI elements
defaultLineColor : ColoruiSystem.js:83Default outline color for UI elements
defaultLineWidth : numberuiSystem.js:96Default line width for UI elements
defaultShadowBlur : numberuiSystem.js:115Size of shadow blur
defaultShadowColor : ColoruiSystem.js:113Color for shadow
defaultShadowOffset : Vector2uiSystem.js:117Offset of shadow blur
defaultSlice : TileSlice|undefineduiSystem.js:121Style to draw UI elements with in place of their rectangle, tinted by their color, undefined for rectangles; needs the drawUtilities plugin
defaultSoundClick : Sound|undefineduiSystem.js:111Default sound when interactive UI element is clicked
defaultSoundPress : Sound|undefineduiSystem.js:105Default sound when interactive UI element is pressed
defaultSoundRelease : Sound|undefineduiSystem.js:108Default sound when interactive UI element is released
defaultTextColor : ColoruiSystem.js:85Default text color for UI elements
defaultTextFitScale : numberuiSystem.js:100Default scale to use for fitting text to object
hoverObject : UIObject|undefineduiSystem.js:152Top most object user is over
keyInputObject : UIObject|undefineduiSystem.js:660Object to send keyboard input to (typically a UITextInput), which keeps the keys from the game while set. The keyboard listeners are only attached while this is set, so games that never use text input pay no event-handling cost. To end typing in a field, call its stopEditing(), which also fires its onChange and release sound
lastHoverObject : UIObject|undefineduiSystem.js:155Hover object at start of update
nativeHeight : numberuiSystem.js:126If set ui coords will be renormalized to this canvas height
pressesOverUI : Array<boolean>uiSystem.js:158uiContext : CanvasRenderingContext2D|OffscreenCanvasRenderingContext2DuiSystem.js:146Context to render UI elements to
uiObjects : Array<UIObject>uiSystem.js:144List of all UI elements
destroyObjects()uiSystem.js:690Destroy and remove all objects
drawLine(posA, posB, lineWidth, lineColor)uiSystem.js:544Draw a line to the UI context
drawRect(pos, size, color, lineWidth, lineColor, cornerRadius, gradientColor, shadowColor, shadowBlur, shadowOffset)uiSystem.js:485Draw a rectangle to the UI context
drawSlice(slice, pos, size, color)uiSystem.js:529Draw a TileSlice to the UI context, in place of a rectangle
drawText(text, pos, size, color, lineWidth, lineColor, align, font, fontStyle, applyMaxWidth, textShadow, shadowColor, shadowBlur, shadowOffset)uiSystem.js:593Draw text to the UI context
text stringpos Vector2size Vector2color Color optional, default uiSystem.defaultColorlineWidth number optional, default uiSystem.defaultLineWidthlineColor Color optional, default uiSystem.defaultLineColoralign 'left'|'center'|'right' optional, default centerfont string optional, default uiSystem.defaultFontfontStyle string optionalapplyMaxWidth boolean optional, default truetextShadow Vector2 optionalshadowColor Color optionalshadowBlur number optional, default 0shadowOffset Vector2 optionaldrawTile(pos, size, tileInfo, color, angle, mirror, shadowColor, shadowBlur, shadowOffset)uiSystem.js:570Draw a tile to the UI context
isMouseOverUI() → booleanuiSystem.js:744Check if the mouse is over a visible UI object that can be hovered, or anywhere while the confirm dialog is open, so a game can leave world clicks on the UI alone, on touch too. The UI uses up a click before objects update and gameUpdatePost, so read world clicks there, or check this in gameUpdate, which runs first. Positions are from the last UI update; false while a level editor is open, which has the mouse.
isPressOverUI(button) → booleanuiSystem.js:736Check if a mouse button's press held now began over the UI, a button or a plain panel, till that button is let go, the frame of the release included, so a drag begun on the UI does not drag the world under it, as the 3D camera controls check it
button number optional, default 00 left, 1 middle, 2 right
screenToNative(pos) → Vector2uiSystem.js:640Convert a screen space position to native UI position
pos Vector2setupDragAndDrop(onDrop, onDragEnter, onDragLeave, onDragOver)uiSystem.js:614Setup drag and drop event handlers Automatically prevents defaults and calls the given functions
onDrop DragAndDropCallback optionalwhen a file is dropped
onDragEnter DragAndDropCallback optionalwhen a file is dragged onto the window
onDragLeave DragAndDropCallback optionalwhen a file is dragged off the window
onDragOver DragAndDropCallback optionalcontinuously when dragging over
showConfirmDialog(text, yesCallback, noCallback, size, exitKey) → UIObjectuiSystem.js:828Show a confirmation dialog with Yes/No buttons Centers the dialog on the screen with darkened background
text string optional, default Are you sure?The message to display
yesCallback function optionalCalled when Yes is clicked
noCallback function optionalCalled when No is clicked, or the exit key or gamepad B closes it
size Vector2 optionalSize of the confirmation dialog, the title and buttons are placed by it
exitKey string optional, default EscapeKey that closes the menu as No, gamepad B (button 1) does too
The confirmation menu object