PressureType Class |
Namespace: KSPDev.GUIUtils.TypeFormatters
The PressureType type exposes the following members.
Name | Description | |
---|---|---|
PressureType | Constructs an object from a numeric value. |
Name | Description | |
---|---|---|
Format | Formats the value into a human friendly string with a unit specification. | |
ToString | Returns a string formatted as a human friendly pressure specification. (Overrides ObjectToString.) |
Name | Description | |
---|---|---|
(Double to PressureType) | Coverts a numeric value into a type object. | |
(PressureType to Double) | Converts a type object into a numeric value. |
Name | Description | |
---|---|---|
kiloPascal | Localized suffix for the "kilopascal" units. Scale x1. | |
KilopascalLocTag | Localization tag for the "kilopascal" units. | |
value | A wrapped numeric value. |
Use it as a generic parameter when creating a LocalizableMessage descendants.
The class uses the unit name localizations from the stock module ModuleEnviroSensor. In case of this module is deprecated or the tags are changed, the default English values will be used for the unit names.
public class PressureTypeDemo1 : PartModule { static readonly Message<PressureType> msg1 = new Message<PressureType>( "#TypeDemo_msg1", defaultTemplate: "Pressure is: <<1>>"); void Show() { Debug.Log(msg1.Format(0.051)); // Prints: "Pressure is: 0.051 kPa" Debug.Log(msg1.Format(0.45)); // Prints: "Pressure is: 0.45 kPa" Debug.Log(msg1.Format(95.45)); // Prints: "Pressure is: 95.5 kPa" Debug.Log(msg1.Format(120.45)); // Prints: "Pressure is: 121 kPa" Debug.Log(msg1.Format(9535.45)); // Prints: "Pressure is: 9,536 kPa" } }
Debug.Log(PressureType.Format(0.051)); // Prints: "Pressure is: 0.051 kPa" Debug.Log(PressureType.Format(0.45)); // Prints: "Pressure is: 0.45 kPa" Debug.Log(PressureType.Format(95.45)); // Prints: "Pressure is: 95.5 kPa" Debug.Log(PressureType.Format(120.45)); // Prints: "Pressure is: 121 kPa" Debug.Log(PressureType.Format(9535.45)); // Prints: "Pressure is: 9,536 kPa"
Debug.Log(PressureType.Format(1234.5678, format: "0.0000")); // Prints: "1234.5678 kPa" Debug.Log(PressureType.Format(1234.5678, format: "0.00")); // Prints: "1234.57 kPa" Debug.Log(PressureType.Format(1234.5678, format: "#,##0.00")); // Prints: "1,234.57 kPa"