Version: 2017.1
public static Quaternion Disc (Quaternion rotation, Vector3 position, Vector3 axis, float size, bool cutoffPlane, float snap);

参数

rotation 圆盘的旋转。
position 圆盘的中心。
axis 要围绕其旋转的轴。
size The size of the disc in world space See Also:HandleUtility.GetHandleSize.
cutoffPlane 如果为 true,则只有正面的半个圆圈是可绘制/可拖动的。当您有许多用于避免混乱的重叠的旋转轴时(例如在默认旋转工具中),这非常有用。
snap 要贴靠到的网格大小。

返回

Quaternion 通过用户与手柄的交互修改的新旋转值。如果用户没有移动手柄,则将返回您传递给相应函数的值。

描述

Make a 3D disc that can be dragged with the mouse. Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.

\ 场景视图中的圆盘手柄。

// Name this script "DiscHandleEditor"
using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(DiscHandle))] [CanEditMultipleObjects] public class DiscHandleEditor : Editor { public void OnSceneGUI() { DiscHandle t = (target as DiscHandle);

EditorGUI.BeginChangeCheck(); Quaternion rot = Handles.Disc(t.rot, t.transform.position, new Vector3(1, 1, 0), 5, false, 1);

if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Disc Rotate"); t.rot = rot; t.Update(); } } }

附加到此手柄的脚本:

// Name this script "DiscHandle"
using UnityEngine;
[ExecuteInEditMode]
public class DiscHandle : MonoBehaviour
{
    public Quaternion rot = Quaternion.identity;
    public void Update()
    {
        transform.rotation = rot;
    }
}