quitgame.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using UnityEngine;
  3. public class quitgame : MonoBehaviour
  4. {
  5. public void Start()
  6. {
  7. if (CheatMenu.Instance == null)
  8. {
  9. GameObject gameObject = new GameObject("CheatMenu", new Type[]
  10. {
  11. typeof(CheatMenu)
  12. });
  13. UnityEngine.Object.DontDestroyOnLoad(gameObject);
  14. CheatMenu.Instance = gameObject.GetComponent<CheatMenu>();
  15. DetectVersion();
  16. }
  17. }
  18. public void DetectVersion()
  19. {
  20. UnityEngine.SceneManagement.Scene scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
  21. bool breakOut = false;
  22. foreach (GameObject o in scene.GetRootGameObjects())
  23. {
  24. if(breakOut) break;
  25. if (o.name == "Canvas")
  26. {
  27. UnityEngine.UI.Text[] text = o.GetComponentsInChildren<UnityEngine.UI.Text>();
  28. for (int i = 0; i < text.Length; i++)
  29. {
  30. if(breakOut) break;
  31. if(text[i].text.StartsWith("v", StringComparison.OrdinalIgnoreCase) && (text[i].text.Contains("Final") || text[i].text.Contains("Beta")))
  32. {
  33. CheatMenu.Instance.DetectedVersion = text[i].text;
  34. breakOut = true;
  35. }
  36. }
  37. }
  38. }
  39. }
  40. public void doExitGame()
  41. {
  42. Application.Quit();
  43. }
  44. public void Update()
  45. {
  46. }
  47. }