确定是否有网络
void Awake() {
GetPhotos();
}
void GetPhotos() {
WWWForm form = new WWWForm(); form.AddField("id", "123");
WWW w = new WWW("https://api.magic-store.cn/api/v1/content/get_tm");
while (!w.isDone) { }
if (w.error != null) { Debug.LogError(w.error); }
shijiancuo sjc = JsonUtility.FromJson(w.text);
if (sjc==null)
{
AlgorithmManage.GetInstance().Time_limit = false;
return;
}
long lTime = long.Parse(sjc.tm);
if (lTime > long.Parse( DateTimeToStamp()))
{
AlgorithmManage.GetInstance().Time_limit = false;
}
}
private string DateTimeToStamp()
{
DateTime DateStart = new DateTime(1970, 1, 1, 8, 0, 0);
DateTime Dateend = new DateTime(2018,1, 30, 0, 0, 0);
int a =Convert.ToInt32((Dateend - DateStart).TotalSeconds);
string b = a + "000";
return b;
}