Unity GUI内绘制贝塞尔曲线

用Handles可以直接在GUI下绘制贝塞尔

using UnityEditor;
using UnityEngine;
using System.Collections;

public class GUIBezier : EditorWindow
{
    Vector3 mOri;
    Vector3 mEnd;
    Vector3 mOriTang;
    Vector3 mEndTang;

    [MenuItem("GUIBezierTest/GUIBezier")]
    public static void CallFunc()
    {
        EditorWindow.GetWindow<GUIBezier>();
    }

    void OnGUI()
    {
        mOri = EditorGUILayout.Vector3Field("ori", mOri);
        mOriTang = EditorGUILayout.Vector3Field("oriTang", mOriTang);
        mEnd = EditorGUILayout.Vector3Field("end", mEnd);
        mEndTang = EditorGUILayout.Vector3Field("endTang", mEndTang);

        Handles.DrawBezier(mOri, mEnd, mOriTang, mEndTang, Color.black, null, 2f);
    }
}

Unity GUI内绘制贝塞尔曲线

上一篇:[BZOJ 1028] [JSOI2007] 麻将 【枚举+贪心判断】


下一篇:bin内置函数