Merge branch 'watermark-attribute' of https://github.com/Tryibion/FlaxEngine into Tryibion-watermark-attribute

This commit is contained in:
Wojtek Figat
2024-04-29 12:23:01 +02:00
3 changed files with 60 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
using System;
namespace FlaxEngine;
/// <summary>
/// Used to add a watermark to a string textbox in the editor field
/// </summary>
[Serializable]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class WatermarkAttribute : Attribute
{
/// <summary>
/// The watermark text.
/// </summary>
public string WatermarkText;
/// <summary>
/// The watermark color.
/// </summary>
public uint WatermarkColor;
/// <summary>
/// Initializes a new instance of the <see cref="WatermarkAttribute"/> class.
/// </summary>
/// <param name="text">The watermark text.</param>
public WatermarkAttribute(string text)
{
WatermarkText = text;
WatermarkColor = 0; // default color of watermark in textbox
}
/// <summary>
/// Initializes a new instance of the <see cref="WatermarkAttribute"/> class.
/// </summary>
/// <param name="text">The watermark text.</param>
/// <param name="color">The watermark color. 0 to use default.</param>
public WatermarkAttribute(string text, uint color)
{
WatermarkText = text;
WatermarkColor = color;
}
}

View File

@@ -213,7 +213,7 @@ namespace FlaxEngine.GUI
color *= 0.6f;
Render2D.DrawText(font, _text, color, ref _layout, TextMaterial);
}
else if (!string.IsNullOrEmpty(_watermarkText) && !IsFocused)
else if (!string.IsNullOrEmpty(_watermarkText))
{
Render2D.DrawText(font, _watermarkText, WatermarkTextColor, ref _layout, TextMaterial);
}