DragSpine.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }
  30. if (dragType == DragType.None)
  31. {
  32. Vector3 vec31 = Input.mousePosition - mousePos;
  33. Transform t = GameMain.Instance.MainCamera.gameObject.transform;
  34. Vector3 vec32 = t.TransformDirection(Vector3.right);
  35. Vector3 vec33 = t.TransformDirection(Vector3.forward);
  36. spine.localEulerAngles = rotate;
  37. spine.RotateAround(spine.position, new Vector3(vec32.x, 0.0f, vec32.z), vec31.y / 3f);
  38. spine.RotateAround(spine.position, new Vector3(vec33.x, 0.0f, vec33.z), (-vec31.x / 4.5f));
  39. }
  40. }
  41. }
  42. }