Skip to Content

Text

GnosisUIElementText is a display element (elementId = "Text") backed by TextMeshProUGUI.

Runtime parameters

In addition to built-in element parameters, GnosisUIElementText supports:

  • text (string) - displayed text value.
  • fontSize (float)
  • enableAutoSizing (bool)
  • fontSizeMin (float)
  • fontSizeMax (float)
  • alignment (string) - any TextAlignmentOptions value (for example TopLeft, Center, BottomRight).
  • fontId (string) - TMP_FontAsset id from UnityAssetRegistry.
  • bindings (list) - optional UIBindingHost rows. Each row is:
    • mode (string) - BindTextStep | LocConstTextStep | LocPathTextStep
    • primarySourcePath (string) - used by BindTextStep and LocPathTextStep
    • observerPath (string) - optional extra observer path (for locale refresh, etc.)
    • fallbackValue (string) - row fallback passed into binding step context
    • key (string) - required for LocConstTextStep

Example - bind direct value (BindTextStep)

{ "service": "GameUI", "function": "CreateElement", "parameters": { "elementId": "Text", "parentId": "ui.HudRoot", "parameters": { "name": "ScoreText", "fontId": "fonts.ui.main", "fontSize": 32.0, "enableAutoSizing": true, "fontSizeMin": 18.0, "fontSizeMax": 44.0, "alignment": "Center", "bindings": [ { "mode": "BindTextStep", "primarySourcePath": "Ephemeral.ui.scoreText", "fallbackValue": "0" } ] } } }

Example - localize by constant key (LocConstTextStep)

{ "service": "GameUI", "function": "CreateElement", "parameters": { "elementId": "Text", "parentId": "ui.HudRoot", "parameters": { "name": "TitleLabel", "alignment": "TopLeft", "bindings": [ { "mode": "LocConstTextStep", "key": "LabelSettings", "observerPath": "Persistent.language", "fallbackValue": "Settings" } ] } } }

Example - localize by dynamic path key (LocPathTextStep)

{ "service": "GameUI", "function": "CreateElement", "parameters": { "elementId": "Text", "parentId": "ui.HudRoot", "parameters": { "name": "DynamicLocLabel", "bindings": [ { "mode": "LocPathTextStep", "primarySourcePath": "Ephemeral.ui.dynamicLocKey", "observerPath": "Persistent.language", "fallbackValue": "MissingKey" } ] } } }
Last updated on