.. default-domain:: js .. highlight:: js .. module:: UI :no-index: Service ======= .. module:: UI 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. .. function:: getStockCanvas() The stock UI canvas. :Property: Read-only, cannot be set :rtype: :class:`UI.Canvas` .. function:: addCanvas() Add a new canvas. :rtype: :class:`UI.Canvas` .. note:: If you want to add UI elements to KSPs stock UI canvas, use :func:`UI.getStockCanvas`. .. function:: message(content[, duration[, position[, color[, size]]]]) Display a message on the screen. :param content: Message content. :type content: ``string`` :param duration: Duration before the message disappears, in seconds. Defaults to ``1.0``. :type duration: ``number`` :param position: Position to display the message. Defaults to ``UI.MessagePosition.topCenter``. :type position: :class:`UI.MessagePosition` :param color: The color of the message. Defaults to ``new StdLib.ColorRGBA({ r: 1.0, g: 0.92, b: 0.016, a: 1.0 })``. :type color: :class:`StdLib.ColorRGBA` :param size: Size of the message, differs per position. Defaults to ``2e+01``. :type size: ``number`` .. note:: The message appears just like a stock message, for example quicksave or quickload messages. .. function:: clear([clientOnly]) Remove all user interface elements. :param clientOnly: If true, only remove objects created by the calling client. Defaults to ``false``. :type clientOnly: ``boolean`` .. class:: MessagePosition Message position. .. attribute:: topLeft Top left. .. attribute:: topCenter Top center. .. attribute:: topRight Top right. .. attribute:: bottomCenter Bottom center.