44
Assets/Scripts/CheckUpdates.cs
Normal file
44
Assets/Scripts/CheckUpdates.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CheckUpdates : MonoBehaviour
|
||||
{
|
||||
public static int ClientVersion = 1;
|
||||
public static int 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/CheckUpdates.cs.meta
Normal file
11
Assets/Scripts/CheckUpdates.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 775efbe35cbc92e2d8825c2ea27a4d0b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Scripts/UI_Helpers.cs
Normal file
10
Assets/Scripts/UI_Helpers.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UI_Helpers : MonoBehaviour
|
||||
{
|
||||
public void OpenUrl(string url){
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI_Helpers.cs.meta
Normal file
11
Assets/Scripts/UI_Helpers.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ed3a603205d37eac86efa443f93035f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user