Unity-DebugX/Runtime/Utils/DebugXTextSettings.cs

45 lines
1.8 KiB
C#
Raw Normal View History

2025-02-26 23:39:50 +08:00
using UnityEngine;
namespace DCFApixels
{
public readonly struct DebugXTextSettings
2025-02-26 23:39:50 +08:00
{
public const TextAnchor DEFAULT_TEXT_ANCHOR = TextAnchor.MiddleLeft;
public const int DEFAULT_FONT_SIZE = 16;
public static readonly DebugXTextSettings Default = new DebugXTextSettings(DEFAULT_FONT_SIZE, DEFAULT_TEXT_ANCHOR, default, 0);
public static readonly DebugXTextSettings WorldSpaceScale = Default.SetWorldSpaceScaleFactor(1f);
2025-02-26 23:39:50 +08:00
public readonly int FontSize;
public readonly TextAnchor TextAnchor;
public readonly Color BackgroundColor;
public readonly float WorldSpaceScaleFactor;
2025-02-26 23:39:50 +08:00
public bool IsHasBackground
{
get { return BackgroundColor.a > 0; }
}
public DebugXTextSettings(int fontSize, TextAnchor textAnchor, Color backgroundColor, float worldSpaceScaleFactor)
2025-02-26 23:39:50 +08:00
{
FontSize = fontSize;
TextAnchor = textAnchor;
BackgroundColor = backgroundColor;
WorldSpaceScaleFactor = worldSpaceScaleFactor;
2025-02-26 23:39:50 +08:00
}
public DebugXTextSettings SetSize(int fontSize)
{
return new DebugXTextSettings(fontSize, TextAnchor, BackgroundColor, WorldSpaceScaleFactor);
2025-02-26 23:39:50 +08:00
}
public DebugXTextSettings SetAnchor(TextAnchor textAnchor)
{
return new DebugXTextSettings(FontSize, textAnchor, BackgroundColor, WorldSpaceScaleFactor);
2025-02-26 23:39:50 +08:00
}
public DebugXTextSettings SetBackground(Color backgroundColor)
{
return new DebugXTextSettings(FontSize, TextAnchor, backgroundColor, WorldSpaceScaleFactor);
}
public DebugXTextSettings SetWorldSpaceScaleFactor(float factor)
{
return new DebugXTextSettings(FontSize, TextAnchor, BackgroundColor, factor);
2025-02-26 23:39:50 +08:00
}
}
}