Add option to use Point sampling when drawing textures and sprites in UI via Brushes

This commit is contained in:
Wojtek Figat
2021-05-19 19:48:39 +02:00
parent 1a55e7c734
commit 62cca0682c
4 changed files with 52 additions and 5 deletions

View File

@@ -14,6 +14,12 @@ namespace FlaxEngine.GUI
[HideInEditor]
public GPUTexture Texture;
/// <summary>
/// The texture sampling filter mode.
/// </summary>
[ExpandGroups, Tooltip("The texture sampling filter mode.")]
public BrushFilter Filter = BrushFilter.Linear;
/// <summary>
/// Initializes a new instance of the <see cref="GPUTextureBrush"/> class.
/// </summary>
@@ -36,7 +42,10 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public void Draw(Rectangle rect, Color color)
{
Render2D.DrawTexture(Texture, rect, color);
if (Filter == BrushFilter.Point)
Render2D.DrawTexturePoint(Texture, rect, color);
else
Render2D.DrawTexture(Texture, rect, color);
}
}
}