DragSpine.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. public class DragSpine : BaseDrag
  6. {
  7. private Transform spine;
  8. private Vector3 rotate;
  9. public void Initialize(Transform spine, Maid maid, Func<Vector3> position, Func<Vector3> rotation)
  10. {
  11. base.Initialize(maid, position, rotation);
  12. this.spine = spine;
  13. InitializeGizmo(this.spine);
  14. }
  15. protected override void GetDragType()
  16. {
  17. dragType = DragType.None;
  18. }
  19. protected override void InitializeDrag()
  20. {
  21. base.InitializeDrag();
  22. rotate = spine.localEulerAngles;
  23. }
  24. protected override void Drag()
  25. {
  26. if (isPlaying)
  27. {
  28. maid.GetAnimation().Stop();
  29. OnDragEvent();
  30. }
  31. if (dragType == DragType.None)
  32. {
  33. Vector3 vec31 = Input.mousePosition - mousePos;
  34. Transform t = GameMain.Instance.MainCamera.gameObject.transform;
  35. Vector3 vec32 = t.TransformDirection(Vector3.right);
  36. Vector3 vec33 = t.TransformDirection(Vector3.forward);
  37. spine.localEulerAngles = rotate;
  38. spine.RotateAround(spine.position, new Vector3(vec32.x, 0.0f, vec32.z), vec31.y / 3f);
  39. spine.RotateAround(spine.position, new Vector3(vec33.x, 0.0f, vec33.z), (-vec31.x / 4.5f));
  40. }
  41. }
  42. }
  43. }