From f7bc2def040fe9d641c68a742219c4b0a8c4a15e Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Tue, 8 Apr 2025 22:26:16 +0800 Subject: [PATCH] add wirearc --- Runtime/Gizmos/DebugX.other.cs | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Runtime/Gizmos/DebugX.other.cs diff --git a/Runtime/Gizmos/DebugX.other.cs b/Runtime/Gizmos/DebugX.other.cs new file mode 100644 index 0000000..9686f88 --- /dev/null +++ b/Runtime/Gizmos/DebugX.other.cs @@ -0,0 +1,64 @@ +using DCFApixels.DebugXCore; +using UnityEngine; +using UnityEngine.Rendering; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace DCFApixels +{ + public static class WireArcGizmosExtensions + { + public static DebugX.DrawHandler WireArc(this DebugX.DrawHandler self, Vector3 center, Vector3 normal, Vector3 from, float angle, float radius) + { + return self.Gizmo(new WireArcGizmos(center, normal, from, angle, radius)); + } + } +} + +namespace DCFApixels.DebugXCore +{ + using static DebugX; + using IN = System.Runtime.CompilerServices.MethodImplAttribute; + public struct WireArcGizmos : IGizmo + { + public readonly Vector3 Position; + public readonly Vector3 Normal; + public readonly Vector3 From; + public readonly float Angle; + public readonly float Radius; + [IN(LINE)] + public WireArcGizmos(Vector3 position, Vector3 normal, Vector3 from, float angle, float radius) + { + Position = position; + Normal = normal.CheckNormalOrDefault(); + From = from; + Angle = angle; + Radius = radius; + } + public IGizmoRenderer RegisterNewRenderer() + { + return new Renderer(); + } + + private class Renderer : IGizmoRenderer + { + public int ExecuteOrder => default(WireMat).GetExecuteOrder(); + public bool IsStaticRender => false; + public void Prepare(Camera camera, GizmosList list) { } + public void Render(Camera camera, GizmosList list, CommandBuffer cb) + { +#if UNITY_EDITOR + Color handles_color = Handles.color; + foreach (var gizmo in list) + { + Handles.color = gizmo.Color; + Handles.DrawWireArc(gizmo.Value.Position, gizmo.Value.Normal, gizmo.Value.From, gizmo.Value.Angle, gizmo.Value.Radius); + } + Handles.color = handles_color; +#endif + } + } + } + +}