Description
The CenterHorizontally
field is a member of the TextFlag
enumeration in the Sandbox namespace. It is used to align text or other elements in the center along the X axis. This flag can be combined with other TextFlag
values to achieve the desired text alignment and positioning.
Usage
Use the CenterHorizontally
flag when you want to center text horizontally within a given area. This is particularly useful in UI design where text needs to be centered within a container or a specific region.
To apply this flag, combine it with other TextFlag
values using a bitwise OR operation if needed. Be cautious of combining conflicting flags, as this can lead to undefined behavior.
Example
// Example of using TextFlag.CenterHorizontally
Graphics.DrawText("Hello, World!", new Vector2(100, 50), TextFlag.CenterHorizontally);