Click or drag to resize

ScreenMessaging Class

Helper class to present global UI messages.
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtilsScreenMessaging

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.5 (in KSPDev_Utils.2.5.dll) Version: 2.5 for KSP v1
Syntax
C#
public static class ScreenMessaging
Request Example View Source

The ScreenMessaging type exposes the following members.

Methods
  NameDescription
Public methodStatic memberSetColorToRichText
Wraps string into Unity rich-text tags to set a color.
Public methodStatic memberShowErrorScreenMessage
Shows an error message with a default timeout.
Public methodStatic memberShowInfoScreenMessage
Shows an info message with a default timeout.
Public methodStatic memberShowInfoScreenMessageWithTimeout
Shows an info message with the specified timeout.
Public methodStatic memberShowPriorityScreenMessage
Shows an important message with a default timeout.
Public methodStatic memberShowPriorityScreenMessageWithTimeout
Shows an important message with the specified timeout.
Public methodStatic memberShowScreenMessage(ScreenMessageStyle, Single, String, Object)
Shows a formatted message with the specified location and timeout.
Public methodStatic memberShowScreenMessage(ScreenMessageStyle, Single, Color, String, Object)
Shows a formatted message with the specified location and timeout.
Public methodStatic memberShowWarningScreenMessage
Shows a warning message with a default timeout.
Top
Fields
  NameDescription
Public fieldStatic memberDefaultErrorTimeout
Default timeout for a UI message that reports an error.
Public fieldStatic memberDefaultMessageTimeout
Default timeout for a regular UI message.
Public fieldStatic memberDefaultWarningTimeout
Default timeout for a UI message that warns about unusual conditions.
Public fieldStatic memberErrorColor
Default color for the error messages.
Public fieldStatic memberWarningColor
Default color for the warning messages.
Top
Remarks
The actual representation of the different priority messages depends on the KSP version. As a rule of thumb use the following reasons when deciding how to show a message: Important messages should be show as "priority". It's assumed that UI layout is build so what that such messages won't be missed.Messages that only give status update and can be safely ignored by the player should be reported as "info". They will show up in UI but not necessarily bring user's attention.
Examples
class MyMod : MonoBehaviour {
  void Update() {
    if (Input.GetKeyDown("1")) {
      ScreenMessaging.ShowPriorityScreenMessage("Key pressed in frame #{0}", Time.frameCount);
    }
  }
}
See Also