Skip to content

Game.UI.Editor.Compass

Assembly: Assembly-CSharp.dll
Namespace: Game.UI.Editor

Type: class

Base: Game.UI.Widgets.Widget

Summary:
A simple UI widget representing a compass heading. It polls a user-provided delegate (Func) each update to obtain the current angle. When the angle changes, the widget flags property changes so the UI system can react. The current angle is also written to JSON via WriteProperties under the "angle" property name.


Fields

  • private float m_Angle
    Stores the last-known angle value used for change detection and for serialization.

  • public System.Func<float> angle
    A delegate the widget calls each Update() to obtain the current angle. If null, the widget treats the angle as 0f.

Properties

  • This class defines no public properties.

Constructors

  • public Compass()
    No explicit constructor is defined in source; the default parameterless constructor is available. Initialization of runtime state is handled in overrides (Update/WriteProperties) and by assigning the angle delegate.

Methods

  • protected override WidgetChanges Update()
    Calls base.Update(), invokes the angle delegate (if non-null) to get the current angle, compares it with the cached m_Angle, and if different sets the WidgetChanges.Properties flag and updates m_Angle. Returns the accumulated WidgetChanges.

  • protected override void WriteProperties(IJsonWriter writer)
    Calls the base implementation, then writes a JSON property named "angle" with the current m_Angle value (writer.PropertyName("angle"); writer.Write(m_Angle);). This is used for serializing the widget state.

Usage Example

// Create the compass widget and supply a delegate that returns the current heading.
// Replace GetCurrentHeading() with your method of obtaining the angle in degrees/radians.
var compass = new Game.UI.Editor.Compass();
compass.angle = () => GetCurrentHeading();

// When the widget is added to the UI, it will call the delegate each Update() and
// automatically mark itself as having property changes when the angle differs from the last value.
// The angle will also be serialized as the "angle" property via WriteProperties.