2025-02-28 22:28:24 +08:00
using System.Runtime.CompilerServices ;
using UnityEngine ;
2025-03-05 18:50:22 +08:00
namespace DCFApixels
{
2025-02-28 22:28:24 +08:00
using DrawHandler = DebugX . DrawHandler ;
2025-03-05 18:50:22 +08:00
using IN = MethodImplAttribute ;
2025-02-28 22:28:24 +08:00
2025-03-05 18:50:22 +08:00
public static class TextDrawHandlerExtensions
{
private const MethodImplOptions LINE = DebugX . LINE ;
#if DEBUG
private static bool _singleWarningToggle = true ;
#endif
[IN(LINE)]
public static DrawHandler Text ( this DrawHandler h , Vector3 position , object text ) = > h . Text ( position , text , DebugXTextSettings . Default ) ;
[IN(LINE)]
public static DrawHandler Text ( this DrawHandler h , Vector3 position , object text , DebugXTextSettings settings )
{
2025-03-06 13:14:54 +08:00
if ( settings . FontSize < = float . Epsilon )
2025-03-05 18:50:22 +08:00
{
#if DEBUG
if ( _singleWarningToggle )
{
Debug . LogWarning ( "Text rendering requires FontSize > 0, otherwise the text will be invisible. To avoid invalid parameters, use DebugXTextSettings.Default instead of manual instantiation." ) ;
_singleWarningToggle = false ;
}
#endif
settings = settings . SetSize ( DebugXTextSettings . DEFAULT_FONT_SIZE ) ;
}
return h . Gizmo ( new TextGizmo ( position , text , settings ) ) ;
}
2025-02-28 22:28:24 +08:00
}
}