I have two script Loading, and CheckNetwork how do I load the game only if the version of the game match
I would like the script to wait until CheckNetwork finished loading the url and got the result whether the version matched or not.
When the result match, continue loading, else pop up a text then on tap quit the app.
Loading:
- private Image progressBar;
- private void Start()
- {
- StartCoroutine(LoadAsyncOperation());
- }
- IEnumerator LoadAsyncOperation()
- {
- AsyncOperation gameLevel = SceneManager.LoadSceneAsync(3);
- while (gameLevel.progress < 1)
- {
- progressBar.fillAmount = gameLevel.progress;
- yield return new WaitForEndOfFrame();
- }
CheckNetwork
- public string URL = "";
- public string CurrentVersion;
- string latestVersion;
- public GameObject newVersionAvailable;
- private void Start()
- {
- StartCoroutine(LoadTxtData(URL));
- }
- void CheckVersion()
- {
- if(CurrentVersion != latestVersion)
- {
- newVersionAvailable.SetActive(true);
- }
- else
- {
- newVersionAvailable.SetActive(false);
- }
- }
- private IEnumerator LoadTxtData(string url)
- {
- UnityWebRequest www = UnityWebRequest.Get(url);
- yield return www.SendWebRequest();
- latestVersion = www.ToString();
- CheckVersion();
- }
- public void OpenURL(string url)
- {
- Application.OpenURL(url);
- }