UISystem. UIObject

UI Object - Base level object for all UI elements

Constructor

new UIObject(posopt, sizeopt)

Create a UIObject

Parameters:
NameTypeAttributesDefaultDescription
posVector2<optional>
vec2()
sizeVector2<optional>
vec2(1)

Members

activeColor

Properties
TypeDescription
Color

Color of the object when active, uses hoverColor if undefined

canBeHover

Properties
TypeDescription
boolean

True if this can be a hover object

children

Properties
TypeDescription
Array.<UIObject>

A list of this object's children

color

Properties
TypeDescription
Color

Color of the object

cornerRadius

Properties
TypeDescription
number

Corner radius for rounded rects

disabled

Properties
TypeDescription
boolean

Is this object disabled?

disabledColor

Properties
TypeDescription
Color

Color when disabled

dragActivate

Properties
TypeDescription
boolean

Activate when dragged over with mouse held down

extraTouchSize

Properties
TypeDescription
number

Added size to make small buttons easier to touch on mobile devices

font

Properties
TypeDescription
string

Font for this objecct

fontStyle

Properties
TypeDescription
string

Font style for this object or undefined

gradientColor

Properties
TypeDescription
Color

Uses a gradient fill combined with color

hoverColor

Properties
TypeDescription
Color

Color used when hovering over the object

interactive

Properties
TypeDescription
boolean

Is this element interactive

lineColor

Properties
TypeDescription
Color

Color for line drawing

lineWidth

Properties
TypeDescription
number

Width for line drawing

localPos

Properties
TypeDescription
Vector2

Local position of the object

Properties
TypeDescription
boolean

Should this be auto selected by navigation? Must also have valid navigation index.

Properties
TypeDescription
number

Optional navigation order index, lower values are selected first

parent

Properties
TypeDescription
UIObject

This object's parent, position is in parent space

pos

Properties
TypeDescription
Vector2

Screen space position of the object

shadowBlur

Properties
TypeDescription
number

Size of shadow blur

shadowColor

Properties
TypeDescription
Color

Color for shadow, undefined if no shadow

shadowOffset

Properties
TypeDescription
Vector2

Offset of shadow blur

size

Properties
TypeDescription
Vector2

Screen space size of the object

soundClick

Properties
TypeDescription
Sound

Sound when interactive element is clicked

soundPress

Properties
TypeDescription
Sound

Sound when interactive element is pressed

soundRelease

Properties
TypeDescription
Sound

Sound when interactive element is released

text

Properties
TypeDescription
string

Text for this ui object

textColor

Properties
TypeDescription
Color

Color for text

textFitScale

Properties
TypeDescription
number

Scale text to fit in the object

textHeight

Properties
TypeDescription
number

Override for text height

textLineColor

Properties
TypeDescription
number

Color for text line drawing

textLineWidth

Properties
TypeDescription
number

Width for text line drawing

textShadow

Properties
TypeDescription
Vector2

How much to offset the text shadow or undefined

textWidth

Properties
TypeDescription
number

Override for text width

visible

Properties
TypeDescription
boolean

Should this object be drawn

Methods

addChild(child) → {UIObject}

Add a child UIObject to this object, returns child for chaining

Parameters:
NameTypeDescription
childUIObject
Returns:

The child object added

Type: 
UIObject

destroy()

Destroy this object, destroy its children, detach its parent, and mark it for removal

getTextSize() → {Vector2}

Get the size for text with overrides and scale

Returns:
Type: 
Vector2

isActiveObject() → {boolean}

Returns:
  • Is the mouse held onto this element
Type: 
boolean

isHoverObject() → {boolean}

Returns:
  • Is the mouse hovering over this element
Type: 
boolean

isInteractive() → {boolean}

Returns:
  • Can it be interacted with
Type: 
boolean

isMouseOverlapping() → {boolean}

Check if the mouse is overlapping a box in screen space

Returns:
  • True if overlapping
Type: 
boolean

isNavigationObject() → {boolean}

Returns:
  • Is the gamepad or keyboard navigation object
Type: 
boolean

Called when the navigation button is pressed on this object

onChange()

Called when the state of this object changes

onClick()

Called when user clicks on this object

onEnter()

Called when the mouse enters the object

onLeave()

Called when the mouse leaves the object

onPress()

Called when the mouse is pressed while over the object

onRelease()

Called when the mouse is released while over the object

onRender()

Called each frame before object renders

onUpdate()

Called each frame before object updates

removeChild(child)

Remove a child UIObject from this object

Parameters:
NameTypeDescription
childUIObject

render()

Render the object, called automatically by plugin once each frame

renderDebug(visible)

Called if uiDebug is enabled

Parameters:
NameTypeDefaultDescription
visiblebooleantrue

toString() → {string}

Returns string containing info about this object for debugging

Returns:
Type: 
string

update()

Update the object, called automatically by plugin once each frame