diff --git a/Samples/Sample.unity b/Samples/Sample.unity index 483134e..34e287e 100644 --- a/Samples/Sample.unity +++ b/Samples/Sample.unity @@ -622,7 +622,7 @@ MonoBehaviour: m_ColorSpace: -1 m_NumColorKeys: 3 m_NumAlphaKeys: 2 - GradientMultiplier: 2 + GradientMultiplier: 3 Points: - {fileID: 1728437382} - {fileID: 54381892} @@ -1654,7 +1654,7 @@ MonoBehaviour: m_ColorSpace: -1 m_NumColorKeys: 3 m_NumAlphaKeys: 2 - GradientMultiplier: 2 + GradientMultiplier: 1.5 WidthMultiplier: 1 StartLines: - {fileID: 1105319542} @@ -5579,7 +5579,7 @@ MonoBehaviour: m_ColorSpace: -1 m_NumColorKeys: 3 m_NumAlphaKeys: 2 - GradientMultiplier: 2 + GradientMultiplier: 3 Points: - {fileID: 1170244042} - {fileID: 151432312} diff --git a/Samples/Scripts/DebugXSample_Lines.cs b/Samples/Scripts/DebugXSample_Lines.cs index 41a41d3..e0fc25b 100644 --- a/Samples/Scripts/DebugXSample_Lines.cs +++ b/Samples/Scripts/DebugXSample_Lines.cs @@ -1,3 +1,4 @@ +using DCFApixels.DebugXCore.Samples.Internal; using UnityEngine; namespace DCFApixels.DebugXCore.Samples @@ -39,12 +40,7 @@ namespace DCFApixels.DebugXCore.Samples } private Color GetColor(Transform pos1, Transform pos2) { - Vector3 pos = (pos1.localPosition + pos2.localPosition) * 0.5f; - pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier; - pos += Vector3.one * 0.5f; - float t = pos.x + pos.y + pos.z; - t /= 3f; - return Gradient.Evaluate(Mathf.Clamp01(t)); + return Gradient.Evaluate(pos1, pos2, GradientMultiplier); } } } diff --git a/Samples/Scripts/DebugXSample_Other.cs b/Samples/Scripts/DebugXSample_Other.cs index 0560698..d4f5d7f 100644 --- a/Samples/Scripts/DebugXSample_Other.cs +++ b/Samples/Scripts/DebugXSample_Other.cs @@ -1,3 +1,4 @@ +using DCFApixels.DebugXCore.Samples.Internal; using UnityEngine; namespace DCFApixels.DebugXCore.Samples @@ -42,12 +43,7 @@ namespace DCFApixels.DebugXCore.Samples } private Color GetColor(Transform pos1) { - Vector3 pos = pos1.localPosition; - pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier; - pos += Vector3.one * 0.5f; - float t = pos.x + pos.y + pos.z; - t /= 3f; - return Gradient.Evaluate(Mathf.Clamp01(t)); + return Gradient.Evaluate(pos1, GradientMultiplier); } } } \ No newline at end of file diff --git a/Samples/Scripts/DebugXSample_Primitives2D.cs b/Samples/Scripts/DebugXSample_Primitives2D.cs index 5afc3cb..c60549d 100644 --- a/Samples/Scripts/DebugXSample_Primitives2D.cs +++ b/Samples/Scripts/DebugXSample_Primitives2D.cs @@ -1,3 +1,4 @@ +using DCFApixels.DebugXCore.Samples.Internal; using UnityEngine; namespace DCFApixels.DebugXCore.Samples @@ -43,12 +44,7 @@ namespace DCFApixels.DebugXCore.Samples } private Color GetColor(Transform pos1) { - Vector3 pos = pos1.localPosition; - pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier; - pos += Vector3.one * 0.5f; - float t = pos.x + pos.y + pos.z; - t /= 3f; - return Gradient.Evaluate(Mathf.Clamp01(t)); + return Gradient.Evaluate(pos1, GradientMultiplier); } } } diff --git a/Samples/Scripts/DebugXSample_Primitives3D.cs b/Samples/Scripts/DebugXSample_Primitives3D.cs index 8e072f2..888143d 100644 --- a/Samples/Scripts/DebugXSample_Primitives3D.cs +++ b/Samples/Scripts/DebugXSample_Primitives3D.cs @@ -1,3 +1,4 @@ +using DCFApixels.DebugXCore.Samples.Internal; using UnityEngine; namespace DCFApixels.DebugXCore.Samples @@ -44,12 +45,7 @@ namespace DCFApixels.DebugXCore.Samples } private Color GetColor(Transform pos1) { - Vector3 pos = pos1.localPosition; - pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier; - pos += Vector3.one * 0.5f; - float t = pos.x + pos.y + pos.z; - t /= 3f; - return Gradient.Evaluate(Mathf.Clamp01(t)); + return Gradient.Evaluate(pos1, GradientMultiplier); } } } diff --git a/Samples/Scripts/DebugXSample_Raycasts2D.cs b/Samples/Scripts/DebugXSample_Raycasts2D.cs index 25dcfb6..804b02f 100644 --- a/Samples/Scripts/DebugXSample_Raycasts2D.cs +++ b/Samples/Scripts/DebugXSample_Raycasts2D.cs @@ -1,3 +1,4 @@ +using DCFApixels.DebugXCore.Samples.Internal; using UnityEngine; namespace DCFApixels.DebugXCore.Samples @@ -53,24 +54,12 @@ 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(Inverse(GetColor(WarrningPoint))).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.WorldSpaceScale.SetSize(22).SetAnchor(TextAnchor.MiddleCenter)); #endif } private Color GetColor(Transform pos1) { - Vector3 pos = pos1.localPosition; - pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier; - pos += Vector3.one * 0.5f; - float t = pos.x + pos.z; - t /= 2f; - return Gradient.Evaluate(Mathf.Clamp01(t)); - } - private Color Inverse(Color c) - { - var a = c.a; - c = Color.white - c; - c.a = a; - return c; + return Gradient.Evaluate(pos1, GradientMultiplier); } } } diff --git a/Samples/Scripts/DebugXSample_Raycasts3D.cs b/Samples/Scripts/DebugXSample_Raycasts3D.cs index 112cbda..8b7de50 100644 --- a/Samples/Scripts/DebugXSample_Raycasts3D.cs +++ b/Samples/Scripts/DebugXSample_Raycasts3D.cs @@ -1,3 +1,4 @@ +using DCFApixels.DebugXCore.Samples.Internal; using UnityEngine; namespace DCFApixels.DebugXCore.Samples @@ -55,24 +56,12 @@ 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(Inverse(GetColor(WarrningPoint))).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.WorldSpaceScale.SetSize(22).SetAnchor(TextAnchor.MiddleCenter)); #endif } private Color GetColor(Transform pos1) { - Vector3 pos = pos1.localPosition; - pos /= GradientMultiplier == 0 ? 1 : GradientMultiplier; - pos += Vector3.one * 0.5f; - float t = pos.x + pos.z; - t /= 2f; - return Gradient.Evaluate(Mathf.Clamp01(t)); - } - private Color Inverse(Color c) - { - var a = c.a; - c = Color.white - c; - c.a = a; - return c; + return Gradient.Evaluate(pos1, GradientMultiplier); } } } diff --git a/Samples/Scripts/Utils.cs b/Samples/Scripts/Utils.cs new file mode 100644 index 0000000..728bfc3 --- /dev/null +++ b/Samples/Scripts/Utils.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +namespace DCFApixels.DebugXCore.Samples.Internal +{ + internal static class Utils + { + public static Color Evaluate(this Gradient gradient, Transform transform, float m) + { + Vector3 pos = transform.localPosition; + pos /= m == 0 ? 1 : m; + pos += Vector3.one * 0.5f; + float t = pos.x + pos.z; + t /= 2f; + return gradient.Evaluate(Mathf.Clamp01(t)); + } + public static Color Evaluate(this Gradient gradient, Transform transform0, Transform transform1, float m) + { + Vector3 pos = (transform0.localPosition + transform1.localPosition) * 0.5f; + pos /= m == 0 ? 1 : m; + pos += Vector3.one * 0.5f; + float t = pos.x + pos.z; + t /= 3f; + return gradient.Evaluate(Mathf.Clamp01(t)); + } + public static Color Inverse(this Color c) + { + var a = c.a; + c = Color.white - c; + c.a = a; + return c; + } + } +} diff --git a/Samples/Scripts/Utils.cs.meta b/Samples/Scripts/Utils.cs.meta new file mode 100644 index 0000000..ac70589 --- /dev/null +++ b/Samples/Scripts/Utils.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 646aedc98b9a6f3458a27f6d43e85990 \ No newline at end of file