diff --git a/Runtime/Gizmos/Text/DebugXTextSettings.cs b/Runtime/Gizmos/Text/DebugXTextSettings.cs
index e1c9766..7ed0ef3 100644
--- a/Runtime/Gizmos/Text/DebugXTextSettings.cs
+++ b/Runtime/Gizmos/Text/DebugXTextSettings.cs
@@ -1,6 +1,7 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
+using System;
using UnityEngine;
namespace DCFApixels
@@ -8,80 +9,72 @@ namespace DCFApixels
///
/// All additional settings for text rendering are stored here.
///
- public readonly struct DebugXTextSettings
+ public struct DebugXTextSettings
{
public const TextAnchor DEFAULT_TEXT_ANCHOR = TextAnchor.MiddleLeft;
public const int DEFAULT_FONT_SIZE = 16;
+ public const float SCREEN_SPACE_SCALE_BLEND = 0f;
+ public const float WORLD_SPACE_SCALE_BLEND = 1f;
- public const float SCREEN_SPACE_SCALE_FACTOR = 0f;
- public const float WORLD_SPACE_SCALE_FACTOR = 1f;
+ public static readonly DebugXTextSettings ScreenSpace = new DebugXTextSettings(DEFAULT_FONT_SIZE, DEFAULT_TEXT_ANCHOR, Color.clear, 0);
+ public static readonly DebugXTextSettings WorldSpace = ScreenSpace.InWorldSpace();
- public static readonly DebugXTextSettings Default = new DebugXTextSettings(DEFAULT_FONT_SIZE, DEFAULT_TEXT_ANCHOR, default, 0);
- public static readonly DebugXTextSettings WorldSpaceScale = Default.SetWorldSpaceScaleFactor();
-
- ///
- /// Font size. Default is .
- ///
- public readonly int FontSize;
-
- ///
- /// Text alignment. Default is .
- ///
- public readonly TextAnchor TextAnchor;
-
- public readonly Color BackgroundColor;
- public readonly float WorldSpaceScaleFactor;
+ /// Font size. Default is .
+ public int FontSize;
+ /// Text alignment. Default is .
+ public TextAnchor TextAnchor;
+ public Color BackgroundColor;
+ public float WorldSpaceBlendMultiplier;
// ReSharper disable once UnusedMember.Global
- public bool IsHasBackground => BackgroundColor.a > 0;
-
- public DebugXTextSettings(int fontSize, TextAnchor textAnchor, Color backgroundColor, float worldSpaceScaleFactor)
+ public bool IsHasBackground { get { return BackgroundColor.a > 0; } }
+ public DebugXTextSettings(int fontSize, TextAnchor textAnchor, Color backgroundColor, float worldSpaceBlendMultiplier)
{
FontSize = fontSize;
TextAnchor = textAnchor;
BackgroundColor = backgroundColor;
- WorldSpaceScaleFactor = worldSpaceScaleFactor;
+ WorldSpaceBlendMultiplier = worldSpaceBlendMultiplier;
}
///
/// Set font size. Default is .
///
- public DebugXTextSettings SetSize(int fontSize)
+ public DebugXTextSettings Size(int fontSize)
{
- return new DebugXTextSettings(fontSize, TextAnchor, BackgroundColor, WorldSpaceScaleFactor);
+ return new DebugXTextSettings(fontSize, TextAnchor, BackgroundColor, WorldSpaceBlendMultiplier);
}
///
/// Sets text alignment. Default is .
///
- public DebugXTextSettings SetAnchor(TextAnchor textAnchor)
+ public DebugXTextSettings Anchor(TextAnchor textAnchor)
{
- return new DebugXTextSettings(FontSize, textAnchor, BackgroundColor, WorldSpaceScaleFactor);
+ return new DebugXTextSettings(FontSize, textAnchor, BackgroundColor, WorldSpaceBlendMultiplier);
}
///
/// Sets background image color behind text. Ignored if transparent.
///
- public DebugXTextSettings SetBackground(Color backgroundColor)
+ public DebugXTextSettings Background(Color backgroundColor)
{
- return new DebugXTextSettings(FontSize, TextAnchor, backgroundColor, WorldSpaceScaleFactor);
+ return new DebugXTextSettings(FontSize, TextAnchor, backgroundColor, WorldSpaceBlendMultiplier);
}
///
/// Synchronizes the text scale in screen space. The text will remain the same size on the screen.
///
// ReSharper disable once UnusedMember.Global
- public DebugXTextSettings SetScreenSpaceScaleFactor()
+ public DebugXTextSettings InScreenSpace()
{
- return SetCustomSpaceScaleFactor(SCREEN_SPACE_SCALE_FACTOR);
+ return ScreenWorldSpaceBlend(SCREEN_SPACE_SCALE_BLEND);
}
///
/// Synchronizes the text scale in world space. The text will remain the same size on the scene.
///
- public DebugXTextSettings SetWorldSpaceScaleFactor()
+ public DebugXTextSettings InWorldSpace()
{
- return SetCustomSpaceScaleFactor(WORLD_SPACE_SCALE_FACTOR);
+ return ScreenWorldSpaceBlend(WORLD_SPACE_SCALE_BLEND);
}
///
@@ -93,9 +86,59 @@ namespace DCFApixels
/// 1 - world space
/// Values in between [0.00 - 1.00] blend these spaces together.
///
+ public DebugXTextSettings ScreenWorldSpaceBlend(float t)
+ {
+ return new DebugXTextSettings(FontSize, TextAnchor, BackgroundColor, t);
+ }
+
+ #region Obsolete
+ [Obsolete("Use " + nameof(WorldSpaceBlendMultiplier))]
+ public float WorldSpaceScaleFactor
+ {
+ get => WorldSpaceBlendMultiplier;
+ set => WorldSpaceBlendMultiplier = value;
+ }
+
+ [Obsolete("Use " + nameof(ScreenSpace))]
+ public static readonly DebugXTextSettings Default = new DebugXTextSettings(DEFAULT_FONT_SIZE, DEFAULT_TEXT_ANCHOR, default, 0);
+ [Obsolete("Use " + nameof(WorldSpace))]
+ public static readonly DebugXTextSettings WorldSpaceScale = Default.InWorldSpace();
+
+ [Obsolete("Use " + nameof(SCREEN_SPACE_SCALE_BLEND))]
+ public const float SCREEN_SPACE_SCALE_FACTOR = 0f;
+ [Obsolete("Use " + nameof(WORLD_SPACE_SCALE_BLEND))]
+ public const float WORLD_SPACE_SCALE_FACTOR = 1f;
+
+ [Obsolete("Use " + nameof(Size))]
+ public DebugXTextSettings SetSize(int fontSize)
+ {
+ return new DebugXTextSettings(fontSize, TextAnchor, BackgroundColor, WorldSpaceBlendMultiplier);
+ }
+ [Obsolete("Use " + nameof(Anchor))]
+ public DebugXTextSettings SetAnchor(TextAnchor textAnchor)
+ {
+ return new DebugXTextSettings(FontSize, textAnchor, BackgroundColor, WorldSpaceBlendMultiplier);
+ }
+ [Obsolete("Use " + nameof(Background))]
+ public DebugXTextSettings SetBackground(Color backgroundColor)
+ {
+ return new DebugXTextSettings(FontSize, TextAnchor, backgroundColor, WorldSpaceBlendMultiplier);
+ }
+ [Obsolete("Use " + nameof(InScreenSpace))]
+ public DebugXTextSettings SetScreenSpaceScaleFactor()
+ {
+ return SetCustomSpaceScaleFactor(SCREEN_SPACE_SCALE_BLEND);
+ }
+ [Obsolete("Use " + nameof(InWorldSpace))]
+ public DebugXTextSettings SetWorldSpaceScaleFactor()
+ {
+ return SetCustomSpaceScaleFactor(WORLD_SPACE_SCALE_BLEND);
+ }
+ [Obsolete("Use " + nameof(ScreenWorldSpaceBlend))]
public DebugXTextSettings SetCustomSpaceScaleFactor(float factor)
{
return new DebugXTextSettings(FontSize, TextAnchor, BackgroundColor, factor);
}
+ #endregion
}
}
\ No newline at end of file
diff --git a/Runtime/Gizmos/Text/TextDrawHandlerExtensions.cs b/Runtime/Gizmos/Text/TextDrawHandlerExtensions.cs
index 4d13d41..c0906f8 100644
--- a/Runtime/Gizmos/Text/TextDrawHandlerExtensions.cs
+++ b/Runtime/Gizmos/Text/TextDrawHandlerExtensions.cs
@@ -16,7 +16,7 @@ namespace DCFApixels
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);
+ public static DrawHandler Text(this DrawHandler h, Vector3 position, object text) => h.Text(position, text, DebugXTextSettings.ScreenSpace);
[IN(LINE)]
public static DrawHandler Text(this DrawHandler h, Vector3 position, object text, DebugXTextSettings settings)
{
diff --git a/Runtime/Gizmos/Text/TextGizmo.cs b/Runtime/Gizmos/Text/TextGizmo.cs
index 49dbb9c..ab65b1c 100644
--- a/Runtime/Gizmos/Text/TextGizmo.cs
+++ b/Runtime/Gizmos/Text/TextGizmo.cs
@@ -77,7 +77,7 @@ namespace DCFApixels
GUIStyle style = _labelStyle;
var zoom = GetCameraZoom(camera, item.Value.Position);
- float fontSize = Mathf.Lerp(item.Value.Settings.FontSize, item.Value.Settings.FontSize / zoom, item.Value.Settings.WorldSpaceScaleFactor);
+ float fontSize = Mathf.Lerp(item.Value.Settings.FontSize, item.Value.Settings.FontSize / zoom, item.Value.Settings.WorldSpaceBlendMultiplier);
style.fontSize = Mathf.Max(1, Mathf.FloorToInt(fontSize));
style.alignment = item.Value.Settings.TextAnchor;
diff --git a/Samples/Scripts/DebugXSample_Other.cs b/Samples/Scripts/DebugXSample_Other.cs
index d4f5d7f..11fd993 100644
--- a/Samples/Scripts/DebugXSample_Other.cs
+++ b/Samples/Scripts/DebugXSample_Other.cs
@@ -30,7 +30,7 @@ namespace DCFApixels.DebugXCore.Samples
i++; DebugX.Draw(GetColor(Points[i])).BillboardCross(Points[i].position, Points[i].localScale.x);
i++; DebugX.Draw(GetColor(Points[i])).BillboardCircle(Points[i].position, Points[i].localScale.x * RADIUS_M);
i++; DebugX.Draw(GetColor(Points[i])).WireMesh(Points[i].position, Points[i].rotation, Points[i].localScale * RADIUS_M);
- i++; DebugX.Draw(GetColor(Points[i])).Text(Points[i].position, Points[i].name, DebugXTextSettings.WorldSpaceScale.SetSize(26).SetBackground(TextBackgroundColor));
+ i++; DebugX.Draw(GetColor(Points[i])).Text(Points[i].position, Points[i].name, DebugXTextSettings.WorldSpace.SetSize(26).SetBackground(TextBackgroundColor));
i++; DebugX.Draw(GetColor(Points[i])).Dot(Points[i].position);
i++; DebugX.Draw(GetColor(Points[i])).WireDot(Points[i].position);
diff --git a/Samples/Scripts/DebugXSample_Raycasts2D.cs b/Samples/Scripts/DebugXSample_Raycasts2D.cs
index ac69fce..589fcf1 100644
--- a/Samples/Scripts/DebugXSample_Raycasts2D.cs
+++ b/Samples/Scripts/DebugXSample_Raycasts2D.cs
@@ -56,7 +56,7 @@ namespace DCFApixels.DebugXCore.Samples
hit = Physics2D.CapsuleCast(ray.origin, point.localScale, CapsuleDirection2D.Vertical, point.eulerAngles.z, ray.direction, float.PositiveInfinity, int.MaxValue);
DebugX.Draw(GetColor(point)).CapsuleCast2D(ray, point.eulerAngles.z, point.localScale, CapsuleDirection2D.Vertical, hit);
#else
- DebugX.Draw(GetColor(WarrningPoint).Inverse()).Text(WarrningPoint.position, "Add \"DEBUGX_ENABLE_PHYSICS2D\" define", DebugXTextSettings.WorldSpaceScale.SetSize(22).SetAnchor(TextAnchor.MiddleCenter));
+ DebugX.Draw(GetColor(WarrningPoint).Inverse()).Text(WarrningPoint.position, "Add \"DEBUGX_ENABLE_PHYSICS2D\" define", DebugXTextSettings.WorldSpace.SetSize(22).SetAnchor(TextAnchor.MiddleCenter));
#endif
if (Application.isPlaying && RotatedTransform)
diff --git a/Samples/Scripts/DebugXSample_Raycasts3D.cs b/Samples/Scripts/DebugXSample_Raycasts3D.cs
index 5370e96..566bb61 100644
--- a/Samples/Scripts/DebugXSample_Raycasts3D.cs
+++ b/Samples/Scripts/DebugXSample_Raycasts3D.cs
@@ -58,7 +58,7 @@ namespace DCFApixels.DebugXCore.Samples
Physics.CapsuleCast(point1, point2, point.localScale.x * RADIUS_M, ray.direction, out hit, float.PositiveInfinity, int.MaxValue, QueryTriggerInteraction.UseGlobal);
DebugX.Draw(GetColor(point)).CapsuleCast(point1, point2, ray.direction, point.localScale.x * RADIUS_M, hit);
#else
- DebugX.Draw(GetColor(WarrningPoint).Inverse()).Text(WarrningPoint.position, "Add \"DEBUGX_ENABLE_PHYSICS3D\" define", DebugXTextSettings.WorldSpaceScale.SetSize(22).SetAnchor(TextAnchor.MiddleCenter));
+ DebugX.Draw(GetColor(WarrningPoint).Inverse()).Text(WarrningPoint.position, "Add \"DEBUGX_ENABLE_PHYSICS3D\" define", DebugXTextSettings.WorldSpace.SetSize(22).SetAnchor(TextAnchor.MiddleCenter));
#endif
if (Application.isPlaying && RotatedTransform)