DragPointMune.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using UnityEngine;
  2. using Input = MeidoPhotoStudio.Plugin.InputManager;
  3. namespace MeidoPhotoStudio.Plugin
  4. {
  5. public class DragPointMune : DragPointChain
  6. {
  7. private bool isMuneL;
  8. private int inv = 1;
  9. public override void Set(Transform myObject)
  10. {
  11. base.Set(myObject);
  12. isMuneL = myObject.name[5] == 'L'; // Mune_L_Sub
  13. if (isMuneL)
  14. inv *= -1;
  15. }
  16. protected override void ApplyDragType() =>
  17. ApplyProperties(CurrentDragType != DragType.None, false, false);
  18. protected override void OnMouseDown()
  19. {
  20. base.OnMouseDown();
  21. meido.SetMune(false, isMuneL);
  22. }
  23. protected override void OnDoubleClick()
  24. {
  25. if (CurrentDragType != DragType.None)
  26. meido.SetMune(true, isMuneL);
  27. }
  28. protected override void UpdateDragType()
  29. {
  30. if (Input.Control && Input.Alt)
  31. CurrentDragType = Input.Shift ? DragType.RotLocalY : DragType.RotLocalXZ;
  32. else
  33. CurrentDragType = DragType.None;
  34. }
  35. protected override void Drag()
  36. {
  37. if (isPlaying)
  38. meido.Stop = true;
  39. if (CurrentDragType == DragType.RotLocalXZ)
  40. {
  41. Porc(IK, ikCtrlData, ikChain[jointUpper], ikChain[jointMiddle], ikChain[jointLower]);
  42. InitializeRotation();
  43. }
  44. if (CurrentDragType == DragType.RotLocalY)
  45. {
  46. var mouseDelta = MouseDelta();
  47. ikChain[jointLower].localRotation = jointRotation[jointLower];
  48. // TODO: Reorder operands for better performance
  49. ikChain[jointLower].Rotate(Vector3.up * (-mouseDelta.x / 1.5f) * inv);
  50. ikChain[jointLower].Rotate(Vector3.forward * (mouseDelta.y / 1.5f) * inv);
  51. }
  52. }
  53. }
  54. }