diff --git a/Source/Engine/Render2D/Font.cpp b/Source/Engine/Render2D/Font.cpp index 8fcb2e020..41924e50b 100644 --- a/Source/Engine/Render2D/Font.cpp +++ b/Source/Engine/Render2D/Font.cpp @@ -402,7 +402,19 @@ Float2 Font::GetCharPosition(const StringView& text, int32 index, const TextLayo { // Check if there is no need to do anything if (text.IsEmpty()) - return layout.Bounds.Location; + { + Float2 location = layout.Bounds.Location; + if (layout.VerticalAlignment == TextAlignment::Center) + location.Y += layout.Bounds.Size.Y * 0.5f - static_cast(_height) * 0.5f; + else if (layout.VerticalAlignment == TextAlignment::Far) + location.Y += layout.Bounds.Size.Y - static_cast(_height) * 0.5f; + + if (layout.HorizontalAlignment == TextAlignment::Center) + location.X += layout.Bounds.Size.X * 0.5f; + else if (layout.HorizontalAlignment == TextAlignment::Far) + location.X += layout.Bounds.Size.X; + return location; + } // Process text Array lines; diff --git a/Source/Engine/UI/GUI/Common/TextBox.cs b/Source/Engine/UI/GUI/Common/TextBox.cs index 2398d75c5..f99d7140a 100644 --- a/Source/Engine/UI/GUI/Common/TextBox.cs +++ b/Source/Engine/UI/GUI/Common/TextBox.cs @@ -292,7 +292,6 @@ namespace FlaxEngine.GUI float alpha = Mathf.Saturate(Mathf.Cos(_animateTime * CaretFlashSpeed) * 0.5f + 0.7f); alpha = alpha * alpha * alpha * alpha * alpha * alpha; Render2D.FillRectangle(CaretBounds, CaretColor * alpha); - } // Restore rendering state