DebugUI.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace DuckHunter
  6. {
  7. public class DebugUI : MonoBehaviour
  8. {
  9. [SerializeField] Button btnSwitch;
  10. [SerializeField] GameObject debugBox;
  11. [SerializeField] Text textA;
  12. [SerializeField] Slider sliderA;
  13. [SerializeField] Text textB;
  14. [SerializeField] Slider sliderB;
  15. public static DebugUI Instance;
  16. void Awake()
  17. {
  18. if (Instance)
  19. {
  20. Destroy(gameObject);
  21. return;
  22. }
  23. Instance = this;
  24. DontDestroyOnLoad(gameObject);
  25. }
  26. void Start()
  27. {
  28. debugBox.SetActive(false);
  29. btnSwitch.onClick.AddListener(() => debugBox.SetActive(!debugBox.activeSelf));
  30. sliderA.onValueChanged.AddListener((v) =>
  31. {
  32. int finalValue = (int)v;
  33. GameManager.DefaultLevel = finalValue;
  34. textA.text = $"下次从{finalValue}关开始游戏";
  35. });
  36. sliderB.onValueChanged.AddListener((v) =>
  37. {
  38. int finalValue = (int)v;
  39. Time.timeScale = finalValue;
  40. textB.text = $"游戏运行速度:{finalValue}";
  41. });
  42. }
  43. public void Debug9AxisCanNotMove()
  44. {
  45. Debug.Log("9轴动不了时打印");
  46. string accStr = PlayerPrefs.GetString("AccIdentity0", "");
  47. Debug.Log("AccIdentity0:" + accStr);
  48. string magStr = PlayerPrefs.GetString("MagIdentity0", "");
  49. Debug.Log("MagIdentity0:" + magStr);
  50. }
  51. }
  52. }