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.

GET /ui/stock-canvas#

The stock UI canvas.

Response JSON Object:
  • value (UI.Canvas)

POST /ui/add-canvas#

Add a new canvas.

Note

If you want to add UI elements to KSPs stock UI canvas, use GET /ui/stock-canvas.

Response JSON Object:
  • value (UI.Canvas)

POST /ui/message#

Display a message on the screen.

Note

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

Request JSON Object:
  • content (string) – Message content.

  • duration (float) – Duration before the message disappears, in seconds. Optional, defaults to 1.0.

  • position (UI.MessagePosition) – Position to display the message. Optional, defaults to "top_center".

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

  • size (float) – Size of the message, differs per position. Optional, defaults to 2e+01.

POST /ui/clear#

Remove all user interface elements.

Request JSON Object:
  • client_only (bool) – If true, only remove objects created by the calling client. Optional, defaults to false.

MessagePosition

Message position.

Passed and returned as the name of one of its values:

"top_left"

Top left.

"top_center"

Top center.

"top_right"

Top right.

"bottom_center"

Bottom center.