Skip to content

Game.Prefabs.UITrendThresholds

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: System.Object

Summary:
Serializable data container used to define proportion thresholds that control when UI trend arrows (medium or high) are displayed. The class exposes two public float fields, each annotated with Unity's Tooltip attribute so they are editable and documented in the Inspector. Typically used as a sub-object on UI prefabs or components that render trend indicators based on relative change.


Fields

  • public float m_Medium
    Proportion threshold for showing medium-strength trend arrows. This represents the ratio of absolute change to the base/previous value above which a medium arrow should be shown. Configurable in the Unity Inspector via the Tooltip: "Proportion of the actual value over which the medium trend arrows will be shown." No explicit default is provided in code (defaults to 0.0f unless set in Inspector or by code).

  • public float m_High
    Proportion threshold for showing high-strength trend arrows. Represents the ratio of absolute change to the base/previous value above which a high arrow should be shown. Configurable in the Unity Inspector via the Tooltip: "Proportion of the actual value over which the high trend arrows will be shown." No explicit default is provided in code (defaults to 0.0f unless set in Inspector or by code).

Properties

  • This type defines no properties. The thresholds are exposed as public fields for inspector serialization and direct access.

Constructors

  • public UITrendThresholds()
    No explicit constructor is defined in the source; the compiler-provided default parameterless constructor is used. As a [Serializable] class, instances are typically created by Unity when deserialized in the Inspector or can be constructed in code.

Methods

  • This type defines no methods.

Usage Example

// Example: using UITrendThresholds to decide which trend arrow to show
var thresholds = new Game.Prefabs.UITrendThresholds {
    m_Medium = 0.05f, // 5% change -> medium arrow
    m_High = 0.20f    // 20% change -> high arrow
};

float previousValue = 100f;
float currentValue = 125f;
float changeAbs = Math.Abs(currentValue - previousValue);

// protect against division by zero if previousValue can be zero
float proportion = previousValue != 0f ? changeAbs / Math.Abs(previousValue) : (changeAbs > 0f ? float.PositiveInfinity : 0f);

if (proportion >= thresholds.m_High) {
    // show high trend arrow
} else if (proportion >= thresholds.m_Medium) {
    // show medium trend arrow
} else {
    // show small/no trend arrow
}

{{ This class is intended for use in Unity UI prefabs/components within Cities: Skylines 2 mods. Because it uses [Serializable] and public fields with [Tooltip], configure the thresholds in the Inspector for easy tuning. Ensure you handle the case where the baseline/previous value may be zero when computing proportions. }}