Game.UI.Widgets.EulerAnglesField
Assembly: Assembly-CSharp (inferred)
Namespace: Game.UI.Widgets
Type: class
Base: FloatField
Summary:
EulerAnglesField is a UI field widget specialised for editing/storing Euler angles using Unity.Mathematics.float3 as the field type. It overrides the field's min/max defaults to the full single-precision range and provides a conversion from a double4 value (commonly used by the underlying field system) into a float3 by taking the xyz components. Be aware of precision loss when converting from double to float and that the default min/max are extreme values (no practical clamping).
Fields
- This class declares no explicit fields.
The class only defines overridden properties and a conversion method; any backing storage or additional fields are provided by the base FloatField.
Properties
-
protected override float3 defaultMin => new float3(float.MinValue)
Provides the default minimum value for the field. It returns a float3 with each component set to float.MinValue, effectively disabling any practical lower clamping by default. Use a narrower range in derived classes or instances if you need sensible bounds (for example, -360..360 for angles). -
protected override float3 defaultMax => new float3(float.MaxValue)
Provides the default maximum value for the field. It returns a float3 with each component set to float.MaxValue, effectively disabling any practical upper clamping by default. Consider overriding or restricting this if the UI/user input should be constrained.
Constructors
public EulerAnglesField()
No explicit constructor is declared in the source; the class uses the default parameterless constructor inherited from its object/class chain. Initialization logic, if needed, should be placed in lifecycle methods provided by the base class (e.g., OnCreate) or in a derived type.
Methods
public override float3 ToFieldType(double4 value)
Converts an incoming double4 to a float3 by taking the xyz components:return new float3(value.xyz);
. This is the conversion used by the FloatFieldpipeline to translate whatever numeric representation the field system passes in (double4) into the field's actual type (float3). Note that the w component of double4 is ignored. Also note potential precision loss converting double -> float.
Usage Example
// Example: instantiate and convert a double4 to the field type
var field = new EulerAnglesField();
double4 incoming = new double4(10.0, 20.0, 30.0, 0.0);
float3 angles = field.ToFieldType(incoming); // produces float3(10f, 20f, 30f)
Notes and tips: - Because defaultMin/defaultMax are set to float.MinValue/MaxValue, the widget does not enforce practical angular limits by itself. If you want degrees constrained to a typical range (e.g., -180..180 or 0..360), override these properties in a subclass or apply clamping/validation where the field is used. - Converting double4 -> float3 discards the w component; if w encodes meaningful data in your source, handle it before conversion. - Uses Unity.Mathematics types (float3, double4) for performance and deterministic math suitable for DOTS-like systems.