DragSpine.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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, Meido meido, Func<Vector3> position, Func<Vector3> rotation)
  10. {
  11. base.Initialize(meido, 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) meido.IsStop = true;
  27. if (dragType == DragType.None)
  28. {
  29. Vector3 vec31 = Input.mousePosition - mousePos;
  30. Transform t = GameMain.Instance.MainCamera.gameObject.transform;
  31. Vector3 vec32 = t.TransformDirection(Vector3.right);
  32. Vector3 vec33 = t.TransformDirection(Vector3.forward);
  33. spine.localEulerAngles = rotate;
  34. spine.RotateAround(spine.position, new Vector3(vec32.x, 0.0f, vec32.z), vec31.y / 3f);
  35. spine.RotateAround(spine.position, new Vector3(vec33.x, 0.0f, vec33.z), (-vec31.x / 4.5f));
  36. }
  37. }
  38. }
  39. }