unity编辑器绘制扇形
使用
UnityEditor.Handles.DrawSolidArc
using UnityEngine; using UnityEditor; public class DrawSectorHandles : MonoBehaviour { public float radius = 5f; // 扇形半径 public float angle = 90f; // 扇形角度 public Color arcColor = Color.red; // 扇形颜色 void OnDrawGizmos() { // 设置颜色 Handles.color = arcColor; // 计算扇形起点和终点的方向 Vector3 forward = transform.forward; // 扇形的正前方向 Vector3 fromDirection = Quaternion.Euler(0, -angle / 2, 0) * forward; // 扇形左边界 // 绘制实心扇形 Handles.DrawSolidArc(transform.position, Vector3.up, fromDirection, angle, radius); } }