VelocityTypeFormat Method |
Namespace: KSPDev.GUIUtils.TypeFormatters
public static string Format( double value, Nullable<double> scale = null, string format = null )
The unknown scales will be rounded up to the closest known scale. If this parameter is omitted, then the best scale for the value will be choosen automatically.
The method tries to keep the resulted string meaningful and as short as possible. For this reason the big values may be scaled down and/or rounded.
The base velocity unit in the game is m/s. I.e. value 1.0 in the game units is one meter per second. Keep it in mind when passing the argument.
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"
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"