40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
[CustomEditor(typeof(BezierWay))]
|
|
public class BezierWayEditor : Editor
|
|
{
|
|
public override void OnInspectorGUI()
|
|
{
|
|
DrawDefaultInspector();
|
|
|
|
BezierWay bezierWay = (BezierWay)target;
|
|
|
|
if (GUILayout.Button("Cache Points"))
|
|
{
|
|
bezierWay.CachePoints();
|
|
EditorUtility.SetDirty(bezierWay);
|
|
}
|
|
|
|
if (GUILayout.Button("Clear Points"))
|
|
{
|
|
bezierWay._points.Clear();
|
|
EditorUtility.SetDirty(bezierWay);
|
|
}
|
|
|
|
EditorGUILayout.Space();
|
|
EditorGUILayout.LabelField("Points Count", bezierWay.PointsCount.ToString());
|
|
|
|
// Предпросмотр кривой
|
|
if (bezierWay.PointsCount >= 2)
|
|
{
|
|
EditorGUILayout.Space();
|
|
EditorGUILayout.LabelField("Preview", EditorStyles.boldLabel);
|
|
|
|
float previewT = EditorGUILayout.Slider("Position", 0f, 0f, 1f);
|
|
Vector3 previewPoint = bezierWay.GetPoint(previewT);
|
|
EditorGUILayout.Vector3Field("Point Position", previewPoint);
|
|
}
|
|
}
|
|
}
|