Skip to content

Game.UI.Widgets.Float2InputField

Assembly:
Assembly-CSharp

Namespace: Game.UI.Widgets

Type:
class

Base:
FloatField

Summary:
A UI input field specialized for two-component single-precision vectors (Unity.Mathematics.float2). It adapts the generic FloatField to work with float2 values, providing default min/max bounds and a conversion from the field's internal double4 representation to float2. Useful for editing 2D vector values in the game's UI (position, offset, 2D parameters, etc.). Note: conversion from double4 to float2 uses only the x and y components and will cast from double to float (possible precision loss).


Fields

  • This class does not declare any new instance fields.
    All storage/fields (if any) are inherited from the FloatField base class.

Properties

  • protected override Unity.Mathematics.float2 defaultMin { get; }
    Returns a float2 initialized to float.MinValue for both components. This is used as the default minimum bound for the input field.

  • protected override Unity.Mathematics.float2 defaultMax { get; }
    Returns a float2 initialized to float.MaxValue for both components. This is used as the default maximum bound for the input field.

Constructors

  • public Float2InputField()
    No explicit constructor is declared in the source; the class uses the compiler-generated default constructor and relies on base class initialization.

Methods

  • public override Unity.Mathematics.float2 ToFieldType(Unity.Mathematics.double4 value)
    Converts the given double4 (the field's internal numeric representation) to a float2 by taking the x and y components and casting them to float (constructed as new float2(value.xy)). Only the xy components are used; z and w are ignored.

Usage Example

using Unity.Mathematics;
using Game.UI.Widgets;

// Example: converting a double4 read from the field to float2
var field = new Float2InputField();

// Suppose the underlying field system returns a double4 (x, y, z, w)
double4 rawValue = new double4(1.25, -3.5, 0.0, 0.0);

// Convert to float2 for game logic
float2 vec = field.ToFieldType(rawValue); // vec == new float2(1.25f, -3.5f)

Additional notes for modders: - float2 is from the Unity.Mathematics package; ensure your mod references Unity.Mathematics if interacting with this type. - Because the conversion discards z/w and casts double→float, be mindful of any precision or component-loss implications when using this field for values that require higher precision or additional components.