Объявление
public static void CircleHandleCap(int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType);Параметры
controlID | Идентификатор элемента управления для дескриптора. |
position | Положение ручки в пространстве Handles.matrix. |
rotation | Вращение ручки в пространстве Handles.matrix. |
size | The size of the handle in the space of Handles.matrix. Use HandleUtility.GetHandleSize, если вы хотите постоянный размер экранного пространства. |
eventType | Тип события, на который действует дескриптор. Он обрабатывает события EventType.Layout и EventType.Repaint. |
Описание
Рисует круглую ручку. Передайте это в функции обработки.
В событии EventType.Layout вычисляет расстояние ручки до мыши и соответственно вызывает HandleUtility.AddControl.< /p>
При событии EventType.Repaint рисует форму маркера.

Добавьте следующий скрипт в папку Assets как CircleExample.cs и добавьте компонент CircleExample к объекту в сцене.
using UnityEngine;
public class CircleExample : MonoBehaviour {}
Add the following script to Assets/Editor as CircleExampleEditor.cs and select the object with the CircleExample component.
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(CircleExample))]
public class CircleExampleEditor : Editor
{
float size = 1f;
protected virtual void OnSceneGUI()
{
if (Event.current.type == EventType.Repaint)
{
Transform transform = ((CircleExample)target).transform;
Handles.color = Handles.xAxisColor;
Handles.CircleHandleCap(
0,
transform.position + new Vector3(3f, 0f, 0f),
transform.rotation * Quaternion.LookRotation(Vector3.right),
size,
EventType.Repaint
);
Handles.color = Handles.yAxisColor;
Handles.CircleHandleCap(
0,
transform.position + new Vector3(0f, 3f, 0f),
transform.rotation * Quaternion.LookRotation(Vector3.up),
size,
EventType.Repaint
);
Handles.color = Handles.zAxisColor;
Handles.CircleHandleCap(
0,
transform.position + new Vector3(0f, 0f, 3f),
transform.rotation * Quaternion.LookRotation(Vector3.forward),
size,
EventType.Repaint
);
}
}
}