还有一个类似功能的插件SWS
曲线编辑,可用于不规则路线,N个2阶bezier 替代高阶,达到曲线插值 的额性能和速度平衡
为了曲线公衡平滑可以用N个3阶的特性调节细节
BezierMgrEditor.cs
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
[CustomEditor(typeof(BezierMgr))]
public class BezierMgrEditor : Editor
{
private SerializedObject m_Object;
private SerializedProperty m_ShowWayPointInGame;
private SerializedProperty m_IsTest;
private SerializedProperty m_Id;
//called whenever this inspector window is loaded
public void OnEnable()
{
//we create a reference to our script object by passing in the target
m_Object = new SerializedObject(target);
m_ShowWayPointInGame = m_Object.FindProperty("showWayPoint");
m_IsTest = m_Object.FindProperty("isWayPointTest");
m_Id = m_Object.FindProperty("id");
}
//called whenever the inspector gui gets rendered
public override void OnInspectorGUI()
{
//this pulls the relative variables from unity runtime and stores them in the object
m_Object.Update();
this.RenameAll();
GUILayout.BeginHorizontal();
GUILayout.Label("--------------游戏设置--------------");
GUILayout.EndHorizontal();
this.m_Id.intValue = EditorGUILayout.IntField("该路点id:", m_Id.intValue, GUILayout.Width(300.0f));
this.m_ShowWayPointInGame.boolValue = EditorGUILayout.Toggle("游戏中显示路点", m_ShowWayPointInGame.boolValue, GUILayout.Width(300.0f));
this.m_IsTest.boolValue = EditorGUILayout.Toggle("开启路点测试", m_IsTest.boolValue, GUILayout.Width(300.0f));
//waypoint index header
GUILayout.Label("Bezier Points: ", EditorStyles.boldLabel);
GUILayout.BeginHorizontal();
if (GUILayout.Button("add"))
{
AddPoint();
}
if (GUILayout.Button("remove"))
{
RemovePoint();
}
if (GUILayout.Button("remove all"))
{
this.RemoveAllPoints();
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("---------------------------------");
GUILayout.EndHorizontal();
if (points.Count % 3 != 0)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Error:当前路点不为3的整数倍");
GUILayout.EndHorizontal();
}
GUILayout.BeginHorizontal();
GUILayout.Label("----------信---息----------");
GUILayout.EndHorizontal();