84 lines
2.4 KiB
C#
Raw Normal View History

using Assets.Scenes.Ride.Scripts;
using System;
2021-11-09 11:37:10 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts.Scenes
{
public abstract class BaseScene: MonoBehaviour
{
2021-11-09 11:37:10 +08:00
UnityEngine.Ping ping;
bool isNetWorkLose = false;
protected virtual void Awake()
{
Debug.Log("base scene awake");
Application.logMessageReceived += Application_logMessageReceived;
2021-11-12 16:54:55 +08:00
//StopCoroutine("Ping");
//StartCoroutine(Ping());
2021-11-09 11:37:10 +08:00
}
private IEnumerator Ping()
{
while (true)
{
ping = new Ping("47.97.84.8");
2021-11-12 16:21:13 +08:00
yield return new WaitForSeconds(5);
2021-11-09 11:37:10 +08:00
}
}
private void Application_logMessageReceived(string condition, string stackTrace, LogType type)
{
//Debug.Log("application log");
if (type == LogType.Error || type == LogType.Exception)
{
string log = $"time:{ System.DateTime.Now.ToString() }\r\n";
log += $"type:{ type }\r\n";
log += $"msg:{ condition }\r\n";
log += $"stack trace:{ stackTrace }\r\n";
System.IO.File.AppendAllText($"{PFConstants.LogFolder}\\{ System.DateTime.Now.ToString("yyyy-MM-dd") }.txt", log);
//Debug.Log(PFConstants.LogFolder);
}
}
private void OnApplicationQuit()
{
MapUDPService.Dispose();
App.MainDeviceAdapter.Dispose();
2021-11-14 13:55:02 +08:00
Debug.Log("i am Quit");
}
2021-09-13 18:21:43 +08:00
private void OnApplicationPause(bool focus)
{
if (focus)
{
Debug.Log("我休眠了");
}
else
{
UIManager.InitNow();//重置当前时间
}
}
2021-11-09 11:37:10 +08:00
protected virtual void Update()
{
2021-11-12 16:54:55 +08:00
//if (Application.internetReachability == NetworkReachability.NotReachable)
//{
// isNetWorkLose = true;
// App.delayTime = -1;
//}
//else if (null != ping && ping.isDone)
//{
// isNetWorkLose = false;
// App.delayTime = ping.time;
// Debug.Log(App.delayTime);
// ping.DestroyPing();
// ping = null;
//}
2021-11-09 11:37:10 +08:00
}
}
}