DebugFor9AxisCameraLerp.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class DebugFor9AxisCameraLerp : MonoBehaviour
  6. {
  7. static bool openLerp = true;
  8. static float lerpValue = 15f;
  9. Slider slider;
  10. Text text;
  11. Button btn;
  12. void Start()
  13. {
  14. slider = transform.Find("BG/Slider").GetComponent<Slider>();
  15. text = transform.Find("BG/Text").GetComponent<Text>();
  16. btn = transform.Find("BG/Button").GetComponent<Button>();
  17. slider.onValueChanged.AddListener((float v) => {
  18. lerpValue = v;
  19. SetText();
  20. AimHandler.ins.lerpTimeRate = lerpValue;
  21. });
  22. btn.onClick.AddListener(() => {
  23. openLerp = !openLerp;
  24. SetBtnText();
  25. AimHandler.ins.lerpForRotation = openLerp;
  26. });
  27. Init();
  28. }
  29. void Init() {
  30. slider.SetValueWithoutNotify(lerpValue);
  31. SetText();
  32. SetBtnText();
  33. AimHandler.ins.lerpForRotation = openLerp;
  34. AimHandler.ins.lerpTimeRate = lerpValue;
  35. }
  36. void SetText() {
  37. text.text = "插值率:" + lerpValue;
  38. }
  39. void SetBtnText() {
  40. btn.GetComponentInChildren<Text>().text = openLerp ? "插值已开启" : "插值已关闭";
  41. btn.GetComponentInChildren<Text>().color = openLerp ? Color.green : Color.black;
  42. }
  43. }