CheckUpdate.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. public class CheckUpdate : MonoBehaviour
  6. {
  7. public GameObject UpdateButton;
  8. private void Awake()
  9. {
  10. if (UpdateButton != null)
  11. {
  12. UpdateButton.SetActive(false);
  13. }
  14. }
  15. public IEnumerator CheckUpdateCoroutine()
  16. {
  17. if (Application.internetReachability == NetworkReachability.NotReachable)
  18. {
  19. yield break;
  20. }
  21. bool end = false;
  22. GetComponent<GSSReader>().OnLoadEnd.RemoveAllListeners();
  23. GetComponent<GSSReader>().OnLoadEnd.AddListener(() => { EndLoad(); end = true; });
  24. GetComponent<GSSReader>().Reload();
  25. yield return new WaitWhile(() => !end);
  26. end = false;
  27. }
  28. public void EndLoad()
  29. {
  30. GetComponent<OpenURL>().URL = GetComponent<GSSReader>().Datas[0][1];
  31. #if UNITY_STANDALONE_OSX && !UNITY_EDITOR
  32. GetComponent<OpenURL>().URL = GetComponent<GSSReader>().Datas[0][2];
  33. #endif
  34. ContinuousController.instance.NeedUpdate = false;
  35. if (GetComponent<GSSReader>().Datas.Length > 0)
  36. {
  37. if (GetComponent<GSSReader>().Datas[0].Length > 0)
  38. {
  39. ContinuousController.instance.NeedUpdate = GetComponent<GSSReader>().Datas[0][0] != ContinuousController.instance.GameVerString;
  40. }
  41. if (ContinuousController.instance.IgnoreUpdate)
  42. {
  43. ContinuousController.instance.NeedUpdate = false;
  44. }
  45. }
  46. if (ContinuousController.instance.NeedUpdate)
  47. {
  48. Opening.instance.SetUpActiveYesNoObject(
  49. new List<UnityAction>() { () => GetComponent<OpenURL>().Open(), null },
  50. new List<string>()
  51. {
  52. "最新版をDLする",
  53. "今はDLしない"
  54. },
  55. Message(),
  56. true);
  57. }
  58. if (UpdateButton != null)
  59. {
  60. UpdateButton.SetActive(ContinuousController.instance.NeedUpdate);
  61. }
  62. string Message() { return "このゲームの最新版があります。\n 最新版をDLしますか?\n(verが違う相手とはと対戦出来ません)"; };
  63. }
  64. }