DragPointMeido.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. using static CustomGizmo;
  6. internal abstract class DragPointMeido : DragPoint
  7. {
  8. protected const int jointUpper = 0;
  9. protected const int jointMiddle = 1;
  10. protected const int jointLower = 2;
  11. protected Meido meido;
  12. protected Maid maid;
  13. protected bool isPlaying;
  14. private bool isBone;
  15. public bool IsBone
  16. {
  17. get => isBone;
  18. set
  19. {
  20. if (value != isBone)
  21. {
  22. isBone = value;
  23. ApplyDragType();
  24. }
  25. }
  26. }
  27. public virtual void Initialize(Meido meido, Func<Vector3> position, Func<Vector3> rotation)
  28. {
  29. base.Initialize(position, rotation);
  30. this.meido = meido;
  31. this.maid = meido.Maid;
  32. this.isPlaying = !meido.Stop;
  33. }
  34. public override void AddGizmo(float scale = 0.25f, GizmoMode mode = GizmoMode.Local)
  35. {
  36. base.AddGizmo(scale, mode);
  37. Gizmo.GizmoDrag += (s, a) =>
  38. {
  39. meido.Stop = true;
  40. isPlaying = false;
  41. };
  42. }
  43. protected override void OnMouseDown()
  44. {
  45. base.OnMouseDown();
  46. isPlaying = !meido.Stop;
  47. }
  48. protected void InitializeIK(TBody.IKCMO iKCmo, Transform upper, Transform middle, Transform lower)
  49. {
  50. iKCmo.Init(upper, middle, lower, maid.body0);
  51. }
  52. protected void Porc(TBody.IKCMO ikCmo, Transform upper, Transform middle, Transform lower)
  53. {
  54. IKCtrlData ikData = maid.body0.IKCtrl.GetIKData("左手");
  55. ikCmo.Porc(upper, middle, lower, CursorPosition(), Vector3.zero, ikData);
  56. }
  57. }
  58. }