1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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;
- private void OnDrawGizmos()
- {
- if (BesselPath == null)
- {
- BesselPath = new BesselPath();
- }
- if (Transforms == null || Transforms.Length < 2)
- {
- return;
- }
- BetterList<Vector3> pos = new BetterList<Vector3>();
- 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 < pos.Count; i++)
- {
- Gizmos.DrawSphere(pos[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.DrawLine(previousPoint, currentPoint);
- previousPoint = currentPoint;
- }
- }
- }
- }
|