BesselPathMono.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Core.Utility
  5. {
  6. public class BesselPathMono : MonoBehaviour
  7. {
  8. public Transform[] Transforms;
  9. public BesselPath BesselPath;
  10. private void OnDrawGizmos()
  11. {
  12. if (BesselPath == null)
  13. {
  14. BesselPath = new BesselPath();
  15. }
  16. if (Transforms == null || Transforms.Length < 2)
  17. {
  18. return;
  19. }
  20. List<Vector3> pos = new List<Vector3>();
  21. for (int i = 0; i < Transforms.Length; i++)
  22. {
  23. pos.Add(Transforms[i].position);
  24. }
  25. BesselPath.SetPos(pos);
  26. float bl = 1.0f / 300;
  27. for (float i = 0; i < 300 - 1; i++)
  28. {
  29. Vector3 pos1 = BesselPath.GetValue(i * bl);
  30. Vector3 pos2 = BesselPath.GetValue((i + 1) * bl);
  31. Debug.DrawLine(pos1, pos2, Color.red);
  32. }
  33. }
  34. }
  35. }