Version: 5.6

Handles.DrawWireArc

切换到手册
public static void DrawWireArc (Vector3 center, Vector3 normal, Vector3 from, float angle, float radius);

参数

center 圆形的中心。
normal 圆形的法线。
from 圆周上的点相对于圆心的方向,即圆弧的起点。
angle 圆弧的角度(以度为单位)。
radius 圆形的半径。

注意:如果您希望拥有恒定屏幕大小的手柄,请使用 HandleUtility.GetHandleSize。

描述

在 3D 空间中绘制一个圆弧。


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;

// ...other code... }

// Create a 180 degrees wire arc with a ScaleValueHandle attached to the disc // that lets you modify the "shieldArea" var in the WireArcExample.js [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.ConeCap, 1); } }

附加到此手柄的脚本:

    // WireArcExample.js

var shieldArea : float = 5;