和SphereBoundsHandle的主要区别是这边有radius, height, heightAxis三个参数,没有size参数,其他基本一致
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
public class TestWindow : EditorWindow
{
[MenuItem("Window/TestWindow")]
static void ShowWindow()
{
var window = GetWindow();
window.titleContent = new GUIContent("TestWindow");
window.Show();
}
private CapsuleBoundsHandle _handle;
private void OnEnable()
{
if (null == _handle)
{
_handle = new CapsuleBoundsHandle();
_handle.radius = 1;
_handle.height = 5;
_handle.heightAxis = CapsuleBoundsHandle.HeightAxis.Y;
_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();
}
}
_handle.heightAxis = CapsuleBoundsHandle.HeightAxis.X;
_handle.heightAxis = CapsuleBoundsHandle.HeightAxis.Z;
Original: https://www.cnblogs.com/sailJs/p/16384148.html
Author: yanghui01
Title: 控制手柄-CapsuleBoundsHandle
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/583522/
转载文章受原作者版权保护。转载请注明原作者出处!