using System; using System.Collections.Generic; using CombatLibrary.CombatLibrary.CombatCore.Utility; using UnityEngine; namespace Core.Utility { public class BesselPathMono : MonoBehaviour { public Transform[] Transforms; public BesselPath BesselPath; public ACurve ACurve; public bool isRun; private void OnDrawGizmos() { if (BesselPath == null) { BesselPath = new BesselPath(); } if (!isRun) { if (Transforms == null || Transforms.Length < 2) { return; } List pos = new List(); for (int i = 0; i < Transforms.Length; i++) { pos.Add(Transforms[i].position); } BesselPath.controlPoints = (pos); } Gizmos.color = Color.blue; // 绘制控制点 for (int i = 0; i < BesselPath.controlPoints.Count; i++) { Gizmos.DrawSphere( BesselPath.controlPoints[i], 0.1f); } // 绘制曲线 Vector3 previousPoint = BesselPath.CalculatePoint(0); int segments = 50; for (int i = 1; i <= segments; i++) { float t = i / (float)segments; Vector3 currentPoint = BesselPath.CalculatePoint(t); // Gizmos.DrawSphere(currentPoint, 0.03f); Gizmos.DrawLine(previousPoint, currentPoint); previousPoint = currentPoint; } } } }