mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-18 01:54:37 +08:00
add wirearc
This commit is contained in:
parent
3ee671aed5
commit
f7bc2def04
64
Runtime/Gizmos/DebugX.other.cs
Normal file
64
Runtime/Gizmos/DebugX.other.cs
Normal file
@ -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<WireArcGizmos>
|
||||
{
|
||||
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<WireArcGizmos> RegisterNewRenderer()
|
||||
{
|
||||
return new Renderer();
|
||||
}
|
||||
|
||||
private class Renderer : IGizmoRenderer<WireArcGizmos>
|
||||
{
|
||||
public int ExecuteOrder => default(WireMat).GetExecuteOrder();
|
||||
public bool IsStaticRender => false;
|
||||
public void Prepare(Camera camera, GizmosList<WireArcGizmos> list) { }
|
||||
public void Render(Camera camera, GizmosList<WireArcGizmos> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user