ToolTest01.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using I2.Loc;
  2. using Sirenix.OdinInspector;
  3. using SK.Framework;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using UnityEditor;
  8. using UnityEngine;
  9. public class ToolTest01 : ToolAnimationBase
  10. {
  11. public enum UpdateMode
  12. {
  13. FixedUpdate,
  14. Update,
  15. LateUpdate,
  16. }
  17. [SerializeField] private SimpleBezierCurvePath path;
  18. [SerializeField] private float speed = 0.2f;
  19. [SerializeField] private UpdateMode updateMode = UpdateMode.Update;
  20. private float normalized = 0f;
  21. private Vector3 lastPosition;
  22. public float normailFloor = 0.01f;
  23. public float index;
  24. [HideInInspector]
  25. public MeshPoint meshPoint;
  26. public override void EditorPlayUpdate(ToolAnimationItem toolAnimationItem, bool reverse)
  27. {
  28. if (path == null)
  29. {
  30. return;
  31. }
  32. index += speed * Time.deltaTime;
  33. meshPoint = path.GetPos(index);
  34. meshPoint.position = meshPoint.position + meshPoint.normail.normalized * normailFloor;
  35. toolAnimationItem.toolAnchor.position = Vector3.Lerp(toolAnimationItem.toolAnchor.position, meshPoint.position, 0.5f);
  36. toolAnimationItem.toolAnchor.forward = Vector3.Slerp(toolAnimationItem.toolAnchor.forward, meshPoint.normail, speed);
  37. if (index > 1)
  38. {
  39. index = 0;
  40. toolAnimationItem.isPlaying = false;
  41. }
  42. }
  43. public override void FinishedState(ToolAnimationItem toolAnimationItem, bool reverse)
  44. {
  45. throw new System.NotImplementedException();
  46. }
  47. public override void InitState(ToolAnimationItem toolAnimationItem, bool reverse)
  48. {
  49. throw new System.NotImplementedException();
  50. }
  51. public override void PlayTrigger(ToolAnimationItem toolAnimationItem, bool reverse)
  52. {
  53. throw new System.NotImplementedException();
  54. }
  55. public override void StopPlay(ToolAnimationItem toolAnimationItem, bool reverse)
  56. {
  57. throw new System.NotImplementedException();
  58. }
  59. }