Service#

Provides functionality for drawing and interacting with in-game user interface elements.

Note

For drawing 3D objects in the flight scene, see the Drawing service. User interface elements created by a client are removed when that client disconnects, and when the game scene changes. A client that needs its interface in more than one scene must create it again in each of them.

UI.getStockCanvas()#

The stock UI canvas.

Property:

Read-only, cannot be set

Return type:

UI.Canvas

UI.addCanvas()#

Add a new canvas.

Return type:

UI.Canvas

Note

If you want to add UI elements to KSPs stock UI canvas, use UI.getStockCanvas().

UI.message(content[, duration[, position[, color[, size]]]])#

Display a message on the screen.

Arguments:
  • content (string) – Message content.

  • duration (number) – Duration before the message disappears, in seconds. Defaults to 1.0.

  • position (UI.MessagePosition) – Position to display the message. Defaults to UI.MessagePosition.topCenter.

  • color (StdLib.ColorRGBA) – The color of the message. Defaults to new StdLib.ColorRGBA({ r: 1.0, g: 0.92, b: 0.016, a: 1.0 }).

  • size (number) – Size of the message, differs per position. Defaults to 2e+01.

Note

The message appears just like a stock message, for example quicksave or quickload messages.

UI.clear([clientOnly])#

Remove all user interface elements.

Arguments:
  • clientOnly (boolean) – If true, only remove objects created by the calling client. Defaults to false.

class UI.MessagePosition()#

Message position.

MessagePosition.topLeft#

Top left.

MessagePosition.topCenter#

Top center.

MessagePosition.topRight#

Top right.

MessagePosition.bottomCenter#

Bottom center.