您的位置:首页 > 移动开发 > Unity3D

Unity之Handles缩放控制柄-十四

2014-12-26 19:01 141 查看
Unity编辑器类在Scene下绘制缩放控制柄, 黄色的为绘制一个方向上的方法, 红绿蓝三个是绘制三个方向的



在Editor文件夹下创建脚本HandlerTest

using 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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: