Unity之Handles绘制圆锥体立方体圆柱体五

来源:互联网 发布:好喝健康的知乎 编辑:程序博客网 时间:2024/04/28 06:20

Unity编辑器类在Scene下绘制圆锥体,立方体,球体



在Editor文件夹下创建脚本HandlerTestusing UnityEngine;using System.Collections;using UnityEditor;[CustomEditor(typeof(Arraw))]public class HandlerTest : Editor {    int coneSize = 13;    void OnSceneGUI()    {        Arraw arraw = (Arraw)target;        Handles.color = Color.green;        Handles.ConeCap( 0, arraw.transform.position + new Vector3(15, 0, 0),            arraw.transform.rotation, coneSize);        Handles.color = Color.yellow;        Handles.CubeCap(0, arraw.transform.position + new Vector3(0, 15, 0),            arraw.transform.rotation, 10 );    if (GUI.changed)        {            EditorUtility.SetDirty(arraw);        }    }}Arraw脚本如下,将脚本拖拽到需要绘制圆锥体的对象上即可using UnityEngine;using System.Collections;public class Arraw : MonoBehaviour {    }

















0 0