StatesBackDebug.cs 903 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class StatesBackDebug : MonoBehaviour
  6. {
  7. InputField inputField;
  8. [System.NonSerialized] public int val;
  9. public static StatesBackDebug ins;
  10. void Start()
  11. {
  12. ins = this;
  13. inputField = GetComponentInChildren<InputField>();
  14. //init data
  15. val = PlayerPrefs.GetInt("StatesBack-Count", 0);
  16. RenderByVal();
  17. }
  18. void OnDestroy()
  19. {
  20. if (ins == this) ins = null;
  21. }
  22. public void OnEndEdit() {
  23. val = int.Parse(inputField.text);
  24. if (val < 0) val = 0;
  25. if (val > 499) val = 499;
  26. PlayerPrefs.SetInt("StatesBack-Count", val);
  27. RenderByVal();
  28. }
  29. void RenderByVal() {
  30. inputField.text = "";
  31. inputField.placeholder.GetComponent<Text>().text = "回退帧数:" + val;
  32. }
  33. }