DrawWireArc(Vector3, Vector3, Vector3, float, float, float)
Draws a circular arc in 3D space.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
public static void DrawWireArc(Vector3 center, Vector3 normal, Vector3 from, float angle, float radius, float thickness)
Parameters
The center of the circle in world space.
The normal of the circle in world space.
The direction of the point on the circle circumference, relative to the center, where the arc begins.
The angle of the arc, in degrees.
The radius of the circle in world space units.
Line thickness in UI points (zero thickness draws single-pixel line).
Remarks
The Handles.color and Handles.matrix properties colorize and additionally transform the arc position. Unity ignores (that is, nothing happens) when the current GUI event type is not EventType.Repaint.
DrawWireArc
Wire Arc in the Scene View.
using UnityEditor;using UnityEngine;using System.Collections;//this class should exist somewhere in your projectpublic class WireArcExample : MonoBehaviour{ public float shieldArea;}// Create a 180 degrees wire arc with a ScaleValueHandle attached to the disc// that lets you modify the "shieldArea" value in the WireArcExample[CustomEditor(typeof(WireArcExample))]public class DrawWireArc : Editor{ void OnSceneGUI() { Handles.color = Color.red; WireArcExample myObj = (WireArcExample)target; Handles.DrawWireArc(myObj.transform.position, myObj.transform.up, -myObj.transform.right, 180, myObj.shieldArea); myObj.shieldArea = (float)Handles.ScaleValueHandle(myObj.shieldArea, myObj.transform.position + myObj.transform.forward * myObj.shieldArea, myObj.transform.rotation, 1, Handles.ConeHandleCap, 1); }}
You can use HandleUtility.GetHandleSize to calculate a suitable size for a manipulator handle.
Arc line can be optionally set. Zero thickness draws a one-pixel line. Larger thickness values express line thickness in UI points. For example, a thickness of 1.0 could be two pixels wide on screen if the display zoom is 200% (see EditorGUIUtility.pixelsPerPoint).
thickness
Arcs of varying thickness.
using UnityEngine;using UnityEditor;public class ExampleScript : MonoBehaviour{}// Display arcs of various angles and thickness in the scene view[CustomEditor(typeof(ExampleScript))]public class ExampleEditor : Editor{ public void OnSceneGUI() { var t = target as ExampleScript; var tr = t.transform; var position = tr.position; Handles.color = Color.yellow; for (int i = 0; i < 10; ++i) { var center = position; var start = Vector3.left; var normal = Vector3.forward; var radius = 3 - i * 0.3f; var angle = 40 + 30 * i; Handles.DrawWireArc(center, normal, start, angle, radius, i); } }}
Additional Resources: Handles.lineThickness, Handles.DrawLine, Handles.DrawSolidArc, Handles.DrawWireDisc.