阅读背景:

Unity之Hanles绘制实心弧 和圆-十

来源:互联网 

Unity编辑器类在Scene下绘制实心弧




在Editor文件夹下创建脚本

using UnityEngine;
using System.Collections;
using UnityEditor;


[CustomEditor(typeof(Arraw))]
public class HandlerTest : Editor {

    Vector3[] positions;

    void OnSceneGUI()
    {
        float width = HandleUtility.GetHandleSize(Vector3.zero) * 0.5f;
        Arraw arraw = (Arraw)target;

        Handles.color = new Color(1, 1, 1, 0.5f);
        Handles.DrawSolidArc(arraw.transform.position, arraw.transform.up,
            -arraw.transform.right, 180, arraw.shieldArea);

        if (GUI.changed)
        {
             EditorUtility.SetDirty(arraw);
        }

    }
}





Arraw脚本如下,将其拖拽到需要绘制的对象上即可

using UnityEngine;
using System.Collections;

public class Arraw : MonoBehaviour {

    public float shieldArea = 5;

}
在Editor文件夹下



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: