ForceTypeFormat Method |
Namespace: KSPDev.GUIUtils.TypeFormatters
public static string Format( double value, string format = null )
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 force unit in the game is kilonewton. I.e. value 1.0 in the game units is one kilonewton. Keep it in mind when passing the argument.
Debug.Log(ForceType.Format(0.051)); // Prints: "0.051 kN" Debug.Log(ForceType.Format(0.45)); // Prints: "0.45 kN" Debug.Log(ForceType.Format(95.45)); // Prints: "95.5 kN" Debug.Log(ForceType.Format(120.45)); // Prints: "120 kN" Debug.Log(ForceType.Format(9535.45)); // Prints: "9536 kN"
Debug.Log(ForceType.Format(1234.5678, format: "0.0000")); // Prints: "1234.5678 kN" Debug.Log(ForceType.Format(1234.5678, format: "0.00")); // Prints: "1234.57 kN"