center | The center of the circle in world space. |
normal | The normal of the circle in world space. |
from | 中心を基準として円弧を開始する円周上の方向 |
angle | 円弧の角度 |
radius | The radius of the circle in world space units. |
thickness | Line thickness in UI points (zero thickness draws single-pixel line). |
Draws a circular arc in 3D space.
The Handles.color and Handles.matrix properties colorize and additionally transform the arc position. Unity ignores DrawWireArc
(that is, nothing happens) when the current GUI event type is not Repaint.
Wire Arc in the Scene View.
using UnityEditor; using UnityEngine; using System.Collections;
//this class should exist somewhere in your project public 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 thickness
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).
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); } } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.