MaidFaceLookPane.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. public class MaidFaceLookPane : BasePane
  6. {
  7. private MeidoManager meidoManager;
  8. private Slider lookXSlider;
  9. private Slider lookYSlider;
  10. public MaidFaceLookPane(MeidoManager meidoManager)
  11. {
  12. this.meidoManager = meidoManager;
  13. this.lookXSlider = new Slider(Translation.Get("freeLook", "x"), -0.6f, 0.6f);
  14. this.lookXSlider.ControlEvent += (s, a) => SetMaidLook();
  15. this.lookYSlider = new Slider(Translation.Get("freeLook", "y"), 0.5f, -0.55f);
  16. this.lookYSlider.ControlEvent += (s, a) => SetMaidLook();
  17. }
  18. public void SetMaidLook()
  19. {
  20. if (updating) return;
  21. TBody body = this.meidoManager.ActiveMeido.Maid.body0;
  22. bool isPlaying = this.meidoManager.ActiveMeido.Maid.GetAnimation().isPlaying;
  23. body.offsetLookTarget = new Vector3(lookYSlider.Value * (isPlaying ? 1f : 0.6f), 1f, lookXSlider.Value);
  24. }
  25. public override void Update()
  26. {
  27. TBody body = this.meidoManager.ActiveMeido.Maid.body0;
  28. this.updating = true;
  29. this.lookXSlider.Value = body.offsetLookTarget.z;
  30. this.lookYSlider.Value = body.offsetLookTarget.x;
  31. this.updating = false;
  32. }
  33. public override void Draw(params GUILayoutOption[] layoutOptions)
  34. {
  35. GUI.enabled = this.Enabled;
  36. GUILayout.BeginHorizontal();
  37. lookXSlider.Draw();
  38. lookYSlider.Draw();
  39. GUILayout.EndHorizontal();
  40. }
  41. }
  42. }