DragPointPelvis.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using UnityEngine;
  2. namespace MeidoPhotoStudio.Plugin
  3. {
  4. using Input = InputManager;
  5. public class DragPointPelvis : DragPointMeido
  6. {
  7. private Quaternion pelvisRotation;
  8. protected override void ApplyDragType()
  9. {
  10. if (CurrentDragType == DragType.Ignore) ApplyProperties();
  11. else if (IsBone) ApplyProperties(false, false, false);
  12. else ApplyProperties(CurrentDragType != DragType.None, false, false);
  13. }
  14. protected override void UpdateDragType()
  15. {
  16. CurrentDragType = Input.Alt && !Input.Control
  17. ? Input.Shift ? DragType.RotLocalY : DragType.RotLocalXZ
  18. : OtherDragType() ? DragType.Ignore : DragType.None;
  19. }
  20. protected override void OnMouseDown()
  21. {
  22. base.OnMouseDown();
  23. pelvisRotation = MyObject.rotation;
  24. }
  25. protected override void Drag()
  26. {
  27. if (CurrentDragType == DragType.None) return;
  28. if (isPlaying) meido.Stop = true;
  29. Vector3 mouseDelta = MouseDelta();
  30. if (CurrentDragType == DragType.RotLocalXZ)
  31. {
  32. MyObject.rotation = pelvisRotation;
  33. MyObject.Rotate(camera.transform.forward, mouseDelta.x / 6f, Space.World);
  34. MyObject.Rotate(camera.transform.right, mouseDelta.y / 4f, Space.World);
  35. }
  36. if (CurrentDragType == DragType.RotLocalY)
  37. {
  38. MyObject.rotation = pelvisRotation;
  39. MyObject.Rotate(Vector3.right * (mouseDelta.x / 2.2f));
  40. }
  41. }
  42. }
  43. }