mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-17 17:34:35 +08:00
update sample
This commit is contained in:
parent
9e966edb31
commit
aefcdc69ab
@ -622,7 +622,7 @@ MonoBehaviour:
|
|||||||
m_ColorSpace: -1
|
m_ColorSpace: -1
|
||||||
m_NumColorKeys: 3
|
m_NumColorKeys: 3
|
||||||
m_NumAlphaKeys: 2
|
m_NumAlphaKeys: 2
|
||||||
GradientMultiplier: 2
|
GradientMultiplier: 3
|
||||||
Points:
|
Points:
|
||||||
- {fileID: 1728437382}
|
- {fileID: 1728437382}
|
||||||
- {fileID: 54381892}
|
- {fileID: 54381892}
|
||||||
@ -1654,7 +1654,7 @@ MonoBehaviour:
|
|||||||
m_ColorSpace: -1
|
m_ColorSpace: -1
|
||||||
m_NumColorKeys: 3
|
m_NumColorKeys: 3
|
||||||
m_NumAlphaKeys: 2
|
m_NumAlphaKeys: 2
|
||||||
GradientMultiplier: 2
|
GradientMultiplier: 1.5
|
||||||
WidthMultiplier: 1
|
WidthMultiplier: 1
|
||||||
StartLines:
|
StartLines:
|
||||||
- {fileID: 1105319542}
|
- {fileID: 1105319542}
|
||||||
@ -5579,7 +5579,7 @@ MonoBehaviour:
|
|||||||
m_ColorSpace: -1
|
m_ColorSpace: -1
|
||||||
m_NumColorKeys: 3
|
m_NumColorKeys: 3
|
||||||
m_NumAlphaKeys: 2
|
m_NumAlphaKeys: 2
|
||||||
GradientMultiplier: 2
|
GradientMultiplier: 3
|
||||||
Points:
|
Points:
|
||||||
- {fileID: 1170244042}
|
- {fileID: 1170244042}
|
||||||
- {fileID: 151432312}
|
- {fileID: 151432312}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -39,12 +40,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1, Transform pos2)
|
private Color GetColor(Transform pos1, Transform pos2)
|
||||||
{
|
{
|
||||||
Vector3 pos = (pos1.localPosition + pos2.localPosition) * 0.5f;
|
return Gradient.Evaluate(pos1, pos2, GradientMultiplier);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -42,12 +43,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -43,12 +44,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
namespace DCFApixels.DebugXCore.Samples
|
||||||
@ -44,12 +45,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
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);
|
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);
|
DebugX.Draw(GetColor(point)).CapsuleCast2D(ray, point.eulerAngles.z, point.localScale, CapsuleDirection2D.Vertical, hit);
|
||||||
#else
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using DCFApixels.DebugXCore.Samples.Internal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DCFApixels.DebugXCore.Samples
|
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);
|
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);
|
DebugX.Draw(GetColor(point)).CapsuleCast(point1, point2, ray.direction, point.localScale.x * RADIUS_M, hit);
|
||||||
#else
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
Vector3 pos = pos1.localPosition;
|
return Gradient.Evaluate(pos1, GradientMultiplier);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
Samples/Scripts/Utils.cs
Normal file
33
Samples/Scripts/Utils.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
Samples/Scripts/Utils.cs.meta
Normal file
2
Samples/Scripts/Utils.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 646aedc98b9a6f3458a27f6d43e85990
|
Loading…
Reference in New Issue
Block a user