| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | 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;        public Vector3 strat0ff;        public Vector3 endOff;        private void OnDrawGizmos()        {                        if (BesselPath == null)            {                BesselPath = new BesselPath();            }            if (!isRun)            {                if (Transforms == null || Transforms.Length < 2)                {                    return;                }                List<Vector3> pos = new List<Vector3>();                for (int i = 0; i < Transforms.Length; i++)                {                    pos.Add(Transforms[i].position);                }                BesselPath.controlPoints = (pos);                strat0ff = Transforms[0].InverseTransformPoint(Transforms[1].position);                endOff = Transforms[3].InverseTransformPoint(Transforms[2].position);            }            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;            }        }    }}
 |