From 1c02f3d8fe0e07386bbf826e090bd1e6bf52e6ed Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 7 Aug 2024 17:44:47 +0200 Subject: [PATCH] Add text alignment options to Button --- Source/Engine/UI/GUI/Common/Button.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Common/Button.cs b/Source/Engine/UI/GUI/Common/Button.cs index ff0b776f9..aa4c182cb 100644 --- a/Source/Engine/UI/GUI/Common/Button.cs +++ b/Source/Engine/UI/GUI/Common/Button.cs @@ -62,6 +62,18 @@ namespace FlaxEngine.GUI [EditorDisplay("Text Style"), EditorOrder(2020)] public Color TextColor; + /// + /// Gets or sets the horizontal text alignment within the control bounds. + /// + [EditorDisplay("Text Style"), EditorOrder(2027)] + public TextAlignment HorizontalAlignment { get; set; } = TextAlignment.Center; + + /// + /// Gets or sets the vertical text alignment within the control bounds. + /// + [EditorDisplay("Text Style"), EditorOrder(2028)] + public TextAlignment VerticalAlignment { get; set; } = TextAlignment.Center; + /// /// Gets or sets the brush used for background drawing. /// @@ -262,7 +274,7 @@ namespace FlaxEngine.GUI Render2D.DrawRectangle(clientRect, borderColor, BorderThickness); // Draw text - Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center); + Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, HorizontalAlignment, VerticalAlignment); } ///