Click or drag to resize

VelocityType Constructor

Constructs an object from a numeric value.

Namespace:  KSPDev.GUIUtils.TypeFormatters
Assembly:  KSPDev_Utils.1.0 (in KSPDev_Utils.1.0.dll) Version: 1.0 for KSP v1.6+
Syntax
C#
public VelocityType(
	double value
)
Request Example View Source

Parameters

value
Type: SystemDouble
The numeric value in the base units.
Examples
public class VelocityTypeDemo1 : PartModule {
  static readonly Message<VelocityType> msg1 = new Message<VelocityType>(
      "#TypeDemo_msg1", defaultTemplate: "Speed is: <<1>>");

  void Show() {
    Debug.Log(msg1.Format(0.051));
    // Prints: "Speed is: 0.051m/s"
    Debug.Log(msg1.Format(0.45));
    // Prints: "Speed is: 0.45m/s"
    Debug.Log(msg1.Format(95.45));
    // Prints: "Speed is: 95.5m/s"
    Debug.Log(msg1.Format(120.45));
    // Prints: "Speed is: 121m/s"
    Debug.Log(msg1.Format(9535.45));
    // Prints: "Speed is: 9.54km/s"
  }
}
Examples
Debug.Log(VelocityType.Format(0.051));
// Prints: "Speed is: 0.051m/s"
Debug.Log(VelocityType.Format(0.45));
// Prints: "Speed is: 0.45m/s"
Debug.Log(VelocityType.Format(95.45));
// Prints: "Speed is: 95.5m/s"
Debug.Log(VelocityType.Format(120.45));
// Prints: "Speed is: 121m/s"
Debug.Log(VelocityType.Format(9535.45));
// Prints: "Speed is: 9.54km/s"
Examples
Debug.Log(VelocityType.Format(1234.5678, format: "0.0000"));
// Prints: "1234.5678m/s"
Debug.Log(VelocityType.Format(1234.5678, format: "0.00"));
// Prints: "1234.57m/s"
Debug.Log(VelocityType.Format(1234.5678, format: "#,##0.00"));
// Prints: "1,234.57m/s"
See Also