47 lines
1022 B
C#
47 lines
1022 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CheckUpdates : MonoBehaviour
|
|
{
|
|
public static int ClientVersion = 3;
|
|
public static int ServerVersion;
|
|
|
|
public static bool EverythingOkay => ClientVersion == ServerVersion;
|
|
|
|
public float interval = 30;
|
|
|
|
float t;
|
|
|
|
void Awake(){
|
|
DontDestroyOnLoad(gameObject);
|
|
CheckUpdate();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
t+=Time.deltaTime;
|
|
|
|
if(t > interval){ t=0; CheckUpdate();}
|
|
}
|
|
|
|
public void CheckUpdate(){
|
|
StartCoroutine(checkUpdate());
|
|
}
|
|
|
|
|
|
IEnumerator checkUpdate(){
|
|
WWW req= new WWW(DataManager.API_ENDPOINT + "get_version.php");
|
|
yield return req;
|
|
|
|
Debug.Log("Server version: " + req.text);
|
|
|
|
ServerVersion = int.Parse(req.text);
|
|
if(ServerVersion <= 0){
|
|
LoadingScreen.LoadLevel("maintaince");
|
|
}else if(ServerVersion > ClientVersion){
|
|
LoadingScreen.LoadLevel("update");
|
|
}
|
|
}
|
|
}
|