Skip to content

Game.UI.Editor.TimeOfDayWeightsFieldBuilders

Assembly: Game
Namespace: Game.UI.Editor

Type: class

Base: IFieldBuilderFactory

Summary:
Factory that creates a field builder for Unity.Mathematics.float4 time-of-day weight values. When a member is of type float4 this factory returns a FieldBuilder that builds a grouped widget containing four labeled FloatSliderField widgets (Night, Morning, Day, Evening) and a TimeOfDayWeightsChart. The factory reads optional numeric range and step attributes via WidgetAttributeUtils to configure the sliders.


Fields

This type declares no instance or static fields.

Properties

This type declares no properties.

Constructors

  • public TimeOfDayWeightsFieldBuilders()
    Default public constructor (compiler-provided if not explicitly declared). No special initialization is required.

Methods

  • public FieldBuilder TryCreate(Type memberType, object[] attributes)
    Attempts to create a FieldBuilder for the given member type and attribute set.

Behavior/details: - Returns null if memberType is not typeof(float4). - If memberType == typeof(float4): - Reads slider range with: - float min = 0f, max = 1f by default. - WidgetAttributeUtils.GetNumberRange(attributes, ref min, ref max) to override min/max from attributes. - float step = WidgetAttributeUtils.GetNumberStep(attributes, 0.1f) to determine slider step (default 0.1f). - Obtains FieldInfo for the float4 fields "x", "y", "z", "w". - Returns a FieldBuilder delegate (IValueAccessor -> IWidget) that produces a Group widget with five children: - Four FloatSliderField widgets (paths "x","y","z","w") with display names: - "Night" -> x - "Morning" -> y - "Day" -> z - "Evening" -> w Each slider uses the computed min, max, fractionDigits = 1, step, and an accessor: CastAccessor(new FieldAccessor(accessor, fieldInfo), ToFloat, FromFloat). These cast between the underlying float stored in the float4 and the slider's double-based value representation. - A TimeOfDayWeightsChart widget with min/max and accessor = new CastAccessor(accessor) to visualize the four weights as a chart. - The method contains two local static helper functions used for casting: - static object FromFloat(double value) — converts double to boxed float: (float)value - static double ToFloat(object value) — converts boxed float to double: (float)value

Notes: - The returned widget group expects to operate against an IValueAccessor that exposes the float4 value to be edited; field-level access uses FieldAccessor to target individual components. - fractionDigits = 1 is used for the sliders (one decimal place).

Usage Example

// Example of using the factory to get a FieldBuilder for a float4 member:
var factory = new TimeOfDayWeightsFieldBuilders();
object[] attributes = new object[] { /* optional attributes controlling range/step */ };
FieldBuilder builder = factory.TryCreate(typeof(Unity.Mathematics.float4), attributes);
if (builder != null)
{
    // 'accessor' would be an IValueAccessor that provides access to the float4 field on a target object.
    IValueAccessor accessor = /* obtain or create accessor for the target float4 value */;
    IWidget widget = builder(accessor); // widget is a Group with four sliders + chart
}

Additional tips: - Use WidgetAttributeUtils range/step attributes on the float4 member to customize min, max and step values for the sliders. - The factory expects float4 field component names x/y/z/w; it uses reflection FieldInfo to build per-component accessors.