logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityHudFractionPartRepresentation

    Shows only the fractional part of the bound value — the digits after the decimal point — floored and zero-padded to a fixed width, so it can sit beside UnityHudIntegerPartRepresentation in a flexbox as the small, fast-ticking half of a value split across two elements (e.g. a big "12" beside a smaller "05").

    Inheritance
    object
    UnityHudRepresentation
    UnityHudTextualRepresentation
    UnityHudFractionPartRepresentation
    Implements
    IHudTextRepresentation
    IHudRepresentation
    Inherited Members
    UnityHudTextualRepresentation.CreateRenderer()
    UnityHudRepresentation.FollowsTheme
    UnityHudRepresentation.HasThemedChrome
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.GameUi.Infrastructure.Representations
    Assembly: Serenity.UnityGameUi.Infrastructure.dll
    Syntax
    public sealed class UnityHudFractionPartRepresentation : UnityHudTextualRepresentation, IHudTextRepresentation, IHudRepresentation
    Remarks

    The fraction is always measured as the value's distance to its own floor (value - Math.Floor(value)) — the same floor UnityHudIntegerPartRepresentation shows as the whole part — never the distance to zero-ward truncation. That is what keeps the pair honest for a negative value: floor(-5.3) is -6, and a fraction of 0.70 beside it reconstructs -5.3 exactly (-6 + 0.70 = -5.3). Measuring the fraction from truncation instead (0.30, the distance from -5.3 to -5) would pair "-6" with ".30" — a pair that adds up to -5.7, visibly wrong the moment a bound value counts down through zero.

    Constructors

    UnityHudFractionPartRepresentation()

    Declaration
    public UnityHudFractionPartRepresentation()

    Properties

    Kind

    Declaration
    public override HudRepresentationKind Kind { get; }
    Property Value
    Type Description
    HudRepresentationKind
    Overrides
    UnityHudRepresentation.Kind

    Methods

    Configure(int)

    Configures the digit count. Used by the builder tool.

    Declaration
    public void Configure(int fractionDigits)
    Parameters
    Type Name Description
    int fractionDigits

    How many fraction digits to show, zero-padded.

    FormatValue(CompiledHudBinding)

    Renders the binding's current value as display text, or the binding's fallback when it cannot be read.

    Declaration
    public override string FormatValue(CompiledHudBinding binding)
    Parameters
    Type Name Description
    CompiledHudBinding binding

    The element's value binding.

    Returns
    Type Description
    string

    The text to show.

    Overrides
    UnityHudTextualRepresentation.FormatValue(CompiledHudBinding)
    Remarks

    Always floors, never rounds — see FormatValue(CompiledHudBinding).

    Implements

    IHudTextRepresentation
    IHudRepresentation
    In this article
    © 2026 Serenity. All Rights Reserved