Unity之Handles缩放控制柄-十四

来源:互联网 发布:黑色星期五禁曲 知乎 编辑:程序博客网 时间:2024/04/30 15:35

Unity编辑器类在Scene下绘制缩放控制柄黄色的为绘制一个方向上的方法,  红绿蓝三个是绘制三个方向的






在Editor文件夹下创建脚本HandlerTestusing UnityEngine;using System.Collections;using UnityEditor;[CustomEditor(typeof(Arraw))]public class HandlerTest : Editor {    float rectangleSize = 3;    void OnSceneGUI()    {        float width = HandleUtility.GetHandleSize(Vector3.zero) * 0.5f;        Arraw arraw = (Arraw)target;        Handles.color = Color.red;        //返回旋转角度,绘制三个方向上的比例        arraw.scale = Handles.ScaleHandle(arraw.scale, arraw.transform.position,            arraw.transform.rotation, 5.0f);        Handles.color = Color.yellow;        arraw.scalAAA = Handles.ScaleSlider( arraw.scalAAA, arraw.transform.position,            Vector3.up, Quaternion.identity, 10, HandleUtility.GetHandleSize(arraw.transform.position));        if (GUI.changed)        {             EditorUtility.SetDirty(arraw);        }    }}Arraw脚本如下,将其拖拽到需要绘制的对象上即可using UnityEngine;using System.Collections;public class Arraw : MonoBehaviour {    public Vector3 scale = new Vector3(1, 1, 1);    public float scalAAA = 1.0f;}












0 0