mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-18 01:54:37 +08:00
add defines for physics
This commit is contained in:
parent
45d3885aa2
commit
90e44311d3
@ -25,7 +25,7 @@ namespace DCFApixels.DebugXCore.Internal
|
|||||||
|
|
||||||
private static bool _isCompilation;
|
private static bool _isCompilation;
|
||||||
private bool? _isHasDisableDebugXInBuildSymbols = false;
|
private bool? _isHasDisableDebugXInBuildSymbols = false;
|
||||||
private const string DEFINE_NAME = nameof(DebugXDefines.DISABLE_DEBUGX_INBUILD);
|
private const string DEFINE_NAME = nameof(DebugXDefines.DEBUGX_DISABLE_INBUILD);
|
||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,19 @@ namespace DCFApixels.DebugXCore
|
|||||||
{
|
{
|
||||||
public static class DebugXDefines
|
public static class DebugXDefines
|
||||||
{
|
{
|
||||||
public const bool DISABLE_DEBUGX_INBUILD =
|
public const bool DEBUGX_DISABLE_INBUILD =
|
||||||
|
#if DISABLE_DEBUGX_INBUILD
|
||||||
|
true;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
public const bool DEBUGX_ENABLE_PHYSICS2D =
|
||||||
|
#if DISABLE_DEBUGX_INBUILD
|
||||||
|
true;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
public const bool DEBUGX_ENABLE_PHYSICS3D =
|
||||||
#if DISABLE_DEBUGX_INBUILD
|
#if DISABLE_DEBUGX_INBUILD
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
|
@ -10,6 +10,7 @@ namespace DCFApixels
|
|||||||
private const float ShadowAlphaMultiplier = 0.3f;
|
private const float ShadowAlphaMultiplier = 0.3f;
|
||||||
public readonly partial struct DrawHandler
|
public readonly partial struct DrawHandler
|
||||||
{
|
{
|
||||||
|
#if DEBUGX_ENABLE_PHYSICS3D
|
||||||
#region RaycastHit
|
#region RaycastHit
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
public DrawHandler RaycastHit(RaycastHit hit)
|
public DrawHandler RaycastHit(RaycastHit hit)
|
||||||
@ -21,25 +22,8 @@ namespace DCFApixels
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
[IN(LINE)]
|
|
||||||
public DrawHandler RaycastHit(RaycastHit2D hit)
|
|
||||||
{
|
|
||||||
if (hit.collider != null)
|
|
||||||
{
|
|
||||||
DotDiamond(hit.point);
|
|
||||||
RayArrow(hit.point, hit.normal);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
[IN(LINE)]
|
|
||||||
private void RaycastHit_Internal(float offsetZ, RaycastHit2D hit)
|
|
||||||
{
|
|
||||||
DotDiamond(new Vector3(hit.point.x, hit.point.y, offsetZ));
|
|
||||||
RayArrow(new Vector3(hit.point.x, hit.point.y, offsetZ), hit.normal);
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Raycast
|
#region Raycast
|
||||||
[IN(LINE)] public DrawHandler Raycast(Ray ray, RaycastHit hit) => Raycast(ray.origin, ray.direction, hit);
|
[IN(LINE)] public DrawHandler Raycast(Ray ray, RaycastHit hit) => Raycast(ray.origin, ray.direction, hit);
|
||||||
[IN(LINE)]
|
[IN(LINE)]
|
||||||
@ -143,7 +127,27 @@ namespace DCFApixels
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DEBUGX_ENABLE_PHYSICS2D
|
||||||
|
#region RaycastHit2D
|
||||||
|
[IN(LINE)]
|
||||||
|
public DrawHandler RaycastHit(RaycastHit2D hit)
|
||||||
|
{
|
||||||
|
if (hit.collider != null)
|
||||||
|
{
|
||||||
|
DotDiamond(hit.point);
|
||||||
|
RayArrow(hit.point, hit.normal);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
[IN(LINE)]
|
||||||
|
private void RaycastHit_Internal(float offsetZ, RaycastHit2D hit)
|
||||||
|
{
|
||||||
|
DotDiamond(new Vector3(hit.point.x, hit.point.y, offsetZ));
|
||||||
|
RayArrow(new Vector3(hit.point.x, hit.point.y, offsetZ), hit.normal);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Raycast2D
|
#region Raycast2D
|
||||||
[IN(LINE)] public DrawHandler Raycast2D(Ray ray, RaycastHit2D hit) => Raycast2D(ray.origin, ray.direction, hit);
|
[IN(LINE)] public DrawHandler Raycast2D(Ray ray, RaycastHit2D hit) => Raycast2D(ray.origin, ray.direction, hit);
|
||||||
@ -238,6 +242,7 @@ namespace DCFApixels
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,6 +23,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
|
#if DEBUGX_ENABLE_PHYSICS2D
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const float RADIUS_M = 0.5f;
|
const float RADIUS_M = 0.5f;
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
ray = new Ray(point.position, point.forward);
|
ray = new Ray(point.position, point.forward);
|
||||||
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);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,8 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
public float GradientMultiplier = 5;
|
public float GradientMultiplier = 5;
|
||||||
public Transform[] Points;
|
public Transform[] Points;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
private void OnDrawGizmos()
|
private void OnDrawGizmos()
|
||||||
{
|
{
|
||||||
@ -23,6 +25,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
|
#if DEBUGX_ENABLE_PHYSICS3D
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const float RADIUS_M = 0.5f;
|
const float RADIUS_M = 0.5f;
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ namespace DCFApixels.DebugXCore.Samples
|
|||||||
Vector3 point2 = ray.origin + point.up * point.localScale.y * RADIUS_M * -0.5f;
|
Vector3 point2 = ray.origin + point.up * point.localScale.y * RADIUS_M * -0.5f;
|
||||||
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);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
private Color GetColor(Transform pos1)
|
private Color GetColor(Transform pos1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user