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.addCanvas()#
Add a new canvas.
- Return type:
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 to1.0.position (
UI.MessagePosition) – Position to display the message. Defaults toUI.MessagePosition.topCenter.color (
StdLib.ColorRGBA) – The color of the message. Defaults tonew StdLib.ColorRGBA({ r: 1.0, g: 0.92, b: 0.016, a: 1.0 }).size (
number) – Size of the message, differs per position. Defaults to2e+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 tofalse.