diff --git a/Editor/Settings/DebugXSettings.cs b/Editor/Settings/DebugXSettings.cs index 2f122bb..690ab4b 100644 --- a/Editor/Settings/DebugXSettings.cs +++ b/Editor/Settings/DebugXSettings.cs @@ -25,7 +25,7 @@ namespace DCFApixels.DebugXCore.Internal private static bool _isCompilation; 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() { diff --git a/Runtime/Consts.cs b/Runtime/Consts.cs index 9cf27c9..f82c30c 100644 --- a/Runtime/Consts.cs +++ b/Runtime/Consts.cs @@ -47,7 +47,19 @@ namespace DCFApixels.DebugXCore { 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 true; #else diff --git a/Runtime/Gizmos/DebugX.raycasts.cs b/Runtime/Gizmos/DebugX.raycasts.cs index c240dd4..c2b474f 100644 --- a/Runtime/Gizmos/DebugX.raycasts.cs +++ b/Runtime/Gizmos/DebugX.raycasts.cs @@ -10,6 +10,7 @@ namespace DCFApixels private const float ShadowAlphaMultiplier = 0.3f; public readonly partial struct DrawHandler { +#if DEBUGX_ENABLE_PHYSICS3D #region RaycastHit [IN(LINE)] public DrawHandler RaycastHit(RaycastHit hit) @@ -21,25 +22,8 @@ namespace DCFApixels } 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 - #region Raycast [IN(LINE)] public DrawHandler Raycast(Ray ray, RaycastHit hit) => Raycast(ray.origin, ray.direction, hit); [IN(LINE)] @@ -143,7 +127,27 @@ namespace DCFApixels return this; } #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 [IN(LINE)] public DrawHandler Raycast2D(Ray ray, RaycastHit2D hit) => Raycast2D(ray.origin, ray.direction, hit); @@ -238,6 +242,7 @@ namespace DCFApixels return this; } #endregion +#endif } } -} \ No newline at end of file +} diff --git a/Samples/Scripts/DebugXSample_Raycasts2D.cs b/Samples/Scripts/DebugXSample_Raycasts2D.cs index 9d6153c..3e17740 100644 --- a/Samples/Scripts/DebugXSample_Raycasts2D.cs +++ b/Samples/Scripts/DebugXSample_Raycasts2D.cs @@ -23,6 +23,7 @@ namespace DCFApixels.DebugXCore.Samples private void Draw() { +#if DEBUGX_ENABLE_PHYSICS2D int i = 0; const float RADIUS_M = 0.5f; @@ -49,6 +50,7 @@ namespace DCFApixels.DebugXCore.Samples 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); DebugX.Draw(GetColor(point)).CapsuleCast2D(ray, point.eulerAngles.z, point.localScale, CapsuleDirection2D.Vertical, hit); +#endif } private Color GetColor(Transform pos1) { diff --git a/Samples/Scripts/DebugXSample_Raycasts3D.cs b/Samples/Scripts/DebugXSample_Raycasts3D.cs index 014a3c0..f026b3f 100644 --- a/Samples/Scripts/DebugXSample_Raycasts3D.cs +++ b/Samples/Scripts/DebugXSample_Raycasts3D.cs @@ -9,6 +9,8 @@ namespace DCFApixels.DebugXCore.Samples public float GradientMultiplier = 5; public Transform[] Points; + + #if UNITY_EDITOR private void OnDrawGizmos() { @@ -23,6 +25,7 @@ namespace DCFApixels.DebugXCore.Samples private void Draw() { +#if DEBUGX_ENABLE_PHYSICS3D int i = 0; 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; 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); +#endif } private Color GetColor(Transform pos1) {