You can use the language-direction
(LanguageDirection
) attribute to set the text direction for visual elementsA node of a visual tree that instantiates or derives from the C# VisualElement
class. You can style the look, define the behaviour, and display it on screen as part of the UI. More info
See in Glossary, specifically whether it flows from left to right (LTR) or right to left (RTL). This is important for languages such as Arabic and Hebrew, which users read from right to left. This attribute corresponds to the dir property in HTML and cascades to child elements.
Language direction can impact the text layout behaviors, such as the position of ellipses and punctuation.
Language direction supports the following values:
You can set the language direction in UI Builder, UXML, or C# scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary.
To set the language direction in UXML, use the language-direction
attribute. For example:
<Label text="Hello" language-direction="RTL" />
To set the language direction in C# scripts, use the LanguageDirection
property. For example:
new TextElement() {languageDirection = LanguageDirection.RTL};