DragPointMune.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using UnityEngine;
  2. namespace MeidoPhotoStudio.Plugin
  3. {
  4. using Input = InputManager;
  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) inv *= -1;
  14. }
  15. protected override void ApplyDragType() => ApplyProperties(CurrentDragType != DragType.None, false, false);
  16. protected override void OnMouseDown()
  17. {
  18. base.OnMouseDown();
  19. meido.SetMune(false, isMuneL);
  20. }
  21. protected override void OnDoubleClick()
  22. {
  23. if (CurrentDragType != DragType.None) meido.SetMune(true, isMuneL);
  24. }
  25. protected override void UpdateDragType()
  26. {
  27. if (Input.Control && Input.Alt) CurrentDragType = Input.Shift ? DragType.RotLocalY : DragType.RotLocalXZ;
  28. else CurrentDragType = DragType.None;
  29. }
  30. protected override void Drag()
  31. {
  32. if (isPlaying) meido.Stop = true;
  33. if (CurrentDragType == DragType.RotLocalXZ)
  34. {
  35. Porc(IK, ikCtrlData, ikChain[jointUpper], ikChain[jointMiddle], ikChain[jointLower]);
  36. InitializeRotation();
  37. }
  38. if (CurrentDragType == DragType.RotLocalY)
  39. {
  40. Vector3 mouseDelta = MouseDelta();
  41. ikChain[jointLower].localRotation = jointRotation[jointLower];
  42. ikChain[jointLower].Rotate(Vector3.up * (-mouseDelta.x / 1.5f) * inv);
  43. ikChain[jointLower].Rotate(Vector3.forward * (mouseDelta.y / 1.5f) * inv);
  44. }
  45. }
  46. }
  47. }