Click or drag to resize

AngleType Class

Localized message formatting class for a numeric value that represents an angle. The resulted message may have a unit specification.
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtils.TypeFormattersAngleType

Namespace:  KSPDev.GUIUtils.TypeFormatters
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public sealed class AngleType
Request Example View Source

The AngleType type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleAngleType
Constructs an angle type object.
Top
Methods
  NameDescription
Public methodStatic memberCode exampleFormat
Formats the value into a human friendly string with a unit specification.
Public methodToString
Returns a string formatted as a human friendly angle specification.
(Overrides ObjectToString.)
Top
Operators
Fields
  NameDescription
Public fieldStatic memberunitName
Suffix for the "angle" units (degrees).
Public fieldvalue
A wrapped numeric value.
Top
Remarks
Use it as a generic parameter when creating a LocalizableMessage descendants.
Examples
public class AngleTypeDemo1 : PartModule {
  static readonly Message<AngleType> msg1 = new Message<AngleType>(
      "#TypeDemo_msg1", defaultTemplate: "Angle is: <<1>>");

  // Depending on the current language in the system, this method will present different unit names. 
  void Show() {
    Debug.Log(msg1.Format(0.4));
    // Prints: "Angle is: 0.4°"
    Debug.Log(msg1.Format(0.41));
    // Prints: "Angle is: 0.41°"
    Debug.Log(msg1.Format(1.0));
    // Prints: "Angle is: 1°"
    Debug.Log(msg1.Format(1.41));
    // Prints: "Angle is: 1.4°"
    Debug.Log(msg1.Format(12.555));
    // Prints: "Angle is: 13°"
  }
}
Examples
Debug.Log(AngleType.Format(0.4));
// Prints: "0.4°"
Debug.Log(AngleType.Format(0.41));
// Prints: "0.41°"
Debug.Log(AngleType.Format(1.0));
// Prints: "1°"
Debug.Log(AngleType.Format(1.41));
// Prints: "1.4°"
Debug.Log(AngleType.Format(12.555));
// Prints: "13°"
Examples
Debug.Log(AngleType.Format(1234.5678, format: "0.0000"));
// Prints: "1234.5678°"
Debug.Log(AngleType.Format(1234.5678, format: "0.00"));
// Prints: "1234.57°"
See Also

Reference

KSPDev.GUIUtils.TypeFormattersAngleType