center | 圆的中心。 |
normal | 圆的法线。 |
from | 圆周上点的方向,相对于中心,扇形开始的位置。 |
angle | 扇形的角度,以度为单位。 |
radius | 圆的半径 注意:在您可能希望拥有恒定屏幕尺寸的句柄的地方使用 HandleUtility.GetHandleSize。 |
在 3D 空间中绘制一个圆形扇形(饼图)。
场景视图中的实心圆弧。
using UnityEditor; using UnityEngine;
static class ArcExample { static Vector3 m_Angle = new Vector3(1.5f, .66f, 0f);
// Create an arc at 0, 0, 0 in the Scene view and a slider that changes thes angle of the arc. [InitializeOnLoadMethod] static void Init() => SceneView.duringSceneGui += view => { Handles.DrawLine(new Vector3(1.5f, 0f, 0f), new Vector3(1.5f, 1f, 0f)); var handleSize = HandleUtility.GetHandleSize(m_Angle) * .1f; m_Angle = Handles.Slider(m_Angle, Vector3.up, handleSize, Handles.DotHandleCap, EditorSnapSettings.move.x); m_Angle.y = Mathf.Clamp(m_Angle.y, 0f, 1f); Handles.Label(m_Angle + Vector3.right * handleSize * 2f, $"Angle {m_Angle.y * 360f}");
Handles.DrawSolidArc(Vector3.zero, Vector3.forward, Vector3.up, m_Angle.y * -360f, 1f); }; }