dot big bang

Developer API
Menu

Class UI

All
  • Public
  • Public/Protected
  • All

Hierarchy

  • UI

Index

Methods

canvasToUIPos

  • Returns a UI-position (i.e. position on screen in normalized coordinates) from a position expressed in canvas space, i.e. in CSS pixels from the top-left corner. See also: uiPosToCanvas.

    Parameters

    • canvasPoint: Vector2

      The position in CSS pixels to convert to UI-position units.

    • Optional optionalTarget: Vector2

      When provided, return the UI-position in this Vector2 instead of allocating one.

    Returns Vector2

clear

  • clear(): void
  • Clears the UI, i.e. removes all the elements it contains.

    Returns void

createTextElement

  • Creates and adds a text element (i.e. UITextElement object) to the UI.

    Parameters

    • font: Font

      The Font to use for the text element

    • text: string

      The text to be displayed. This can be dynamically changed later with UITextElement.setText()

    Returns UITextElement

createVoxelObjectElement

  • Creates and adds a VoxelObject element (i.e. UIVoxelObjectElement object) to the UI.

    Parameters

    • voxelObject: VoxelObject

      The VoxelObject to be displayed.

    Returns UIVoxelObjectElement

getElements

  • Gets all the elements that exist in the UI, whatever their type.

    Parameters

    • Optional optionalTarget: UIElement[]

      When provided, return the elements in this array instead of allocating one.

    Returns UIElement[]

getTextElements

  • Gets all the UITextElements that exist in the UI.

    Parameters

    • Optional optionalTarget: UITextElement[]

      When provided, return the elements in this array instead of allocating one.

    Returns UITextElement[]

getVoxelObjectElements

  • Gets all the UIVoxelObjectElement that exist in the UI.

    Parameters

    • Optional optionalTarget: UIVoxelObjectElement[]

      When provided, return the elements in this array instead of allocating one.

    Returns UIVoxelObjectElement[]

isVisible

  • isVisible(): boolean
  • Indicates if the game's UI is currently set to be visible by UI.setVisible.

    Returns boolean

removeElement

  • Remove a given element from the UI.

    Parameters

    • element: UIElement

      The element to remove from the UI.

    Returns void

setVisible

  • setVisible(visible: boolean): void
  • Makes the UI visible or invisible. This is separate from the "No Ingame 2d UI" debug setting in the editor. Both need to be set to visible in order for the UI to be visible.

    Parameters

    • visible: boolean

    Returns void

uiPosToCanvas

  • Returns a position expressed in canvas space (i.e. in CSS pixels from the top-left corner.) from a UI-position (i.e. position on screen in normalized coordinates), See also: canvasToUIPos.

    Parameters

    • uiPos: Vector2

      The position in normalized UI units to convert to CSS pixels.

    • Optional optionalTarget: Vector2

      When provided, returns the value in this Vector2 instead of allocating one.

    Returns Vector2

worldToUIPos

  • Returns a UI-position (i.e. position on screen in normalized coordinates) from a position expressed in world units. The return value is a Vector3, and not a Vector2 as one might expect. This is because the z component indicates whether the point is visible or not. If it's less than 1, it is in front of the camera and therefore potentially visible (it might still be outside the camera frustum). If it's more than 1, it is behind the camera and thus necessarily invisible.

    Parameters

    • worldPosition: Vector3

      The world-unit position to convert to UI-position units.

    • Optional optionalTarget: Vector3

      When provided, return the UI-position in this Vector3 instead of allocating one.

    Returns Vector3