unity 控制点 贝塞尔曲线_Unity曲线编辑器和bezier曲线插值

还有一个类似功能的插件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();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值