public static void DrawWireArc (Vector3 center, Vector3 normal, Vector3 from, float angle, float radius, float thickness= 0.0f);

Parameters

centerThe center of the circle in world space.
normalThe normal of the circle in world space.
from@param from Направление точки в окружности, относительно центра где начинается дуга.
angle@param angle Угол дуги, в градусах.
radiusThe radius of the circle in world space units.
thicknessLine thickness in UI points (zero thickness draws single-pixel line).

Description

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); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961