控制手柄-SphereBoundsHandle

 

# 和SphereBoundsHandle的主要区别是radius和size参数,其他基本一致

using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;

public class TestWindow : EditorWindow
{

    [MenuItem("Window/TestWindow")]
    static void ShowWindow()
    {
        var window = GetWindow<TestWindow>();
        window.titleContent = new GUIContent("TestWindow");
        window.Show();
    }

    private SphereBoundsHandle _handle;

    private void OnEnable()
    {
        if (null == _handle)
        {
            _handle = new SphereBoundsHandle();
            _handle.radius = 3;
            _handle.center = new Vector3(6, 0, 0);
            _handle.handleColor = Color.red;
            _handle.wireframeColor = Color.blue;
            _handle.midpointHandleSizeFunction = (pos) =>
            {
                return 0.2f;
            };
            //_handle.axes = PrimitiveBoundsHandle.Axes.X | PrimitiveBoundsHandle.Axes.Z;
        }

        SceneView.duringSceneGui += OnSceneGUI;
    }

    private void OnDisable()
    {
        SceneView.duringSceneGui -= OnSceneGUI;
    }

    void OnSceneGUI(SceneView view)
    {
        _handle.DrawHandle();
    }

}

 

posted @ 2022-06-16 23:56  yanghui01  阅读(34)  评论(0)    收藏  举报