diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs
index cd7097dae..cb6e11ee0 100644
--- a/Source/Engine/UI/GUI/Control.cs
+++ b/Source/Engine/UI/GUI/Control.cs
@@ -81,6 +81,7 @@ namespace FlaxEngine.GUI
// Style
private Color _backgroundColor = Color.Transparent;
+ private IBrush _backgroundBrush = null;
// Tooltip
@@ -174,6 +175,25 @@ namespace FlaxEngine.GUI
set => _backgroundColor = value;
}
+ ///
+ /// Gets or sets control background brush used to fill the contents. Uses Background Color property as tint color.
+ ///
+ [EditorDisplay("Background Style"), EditorOrder(2001)]
+ public IBrush BackgroundBrush
+ {
+ get => _backgroundBrush;
+ set
+ {
+ _backgroundBrush = value;
+
+#if FLAX_EDITOR
+ // Auto-reset background color so brush is visible as it uses it for tint
+ if (value != null && _backgroundColor == Color.Transparent && FlaxEditor.CustomEditors.CustomEditor.IsSettingValue)
+ _backgroundColor = Color.White;
+#endif
+ }
+ }
+
///
/// Gets or sets the anchor preset used by the control anchors (based on and ).
///
@@ -416,9 +436,14 @@ namespace FlaxEngine.GUI
public virtual void Draw()
{
// Paint Background
- if (_backgroundColor.A > 0.0f)
+ var rect = new Rectangle(Float2.Zero, _bounds.Size);
+ if (BackgroundBrush != null)
{
- Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), _backgroundColor);
+ BackgroundBrush.Draw(rect, _backgroundColor);
+ }
+ else if (_backgroundColor.A > 0.0f)
+ {
+ Render2D.FillRectangle(rect, _backgroundColor);
}
}