84 lines
2.4 KiB
C#
84 lines
2.4 KiB
C#
using Assets.Scenes.Ride.Scripts;
|
|
using System;
|
|
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
|
|
{
|
|
UnityEngine.Ping ping;
|
|
bool isNetWorkLose = false;
|
|
protected virtual void Awake()
|
|
{
|
|
Debug.Log("base scene awake");
|
|
Application.logMessageReceived += Application_logMessageReceived;
|
|
//StopCoroutine("Ping");
|
|
//StartCoroutine(Ping());
|
|
}
|
|
|
|
private IEnumerator Ping()
|
|
{
|
|
while (true)
|
|
{
|
|
ping = new Ping("47.97.84.8");
|
|
yield return new WaitForSeconds(5);
|
|
}
|
|
}
|
|
|
|
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();
|
|
Debug.Log("i am Quit");
|
|
}
|
|
|
|
private void OnApplicationPause(bool focus)
|
|
{
|
|
if (focus)
|
|
{
|
|
Debug.Log("我休眠了");
|
|
}
|
|
else
|
|
{
|
|
UIManager.InitNow();//重置当前时间
|
|
}
|
|
}
|
|
protected virtual void Update()
|
|
{
|
|
//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;
|
|
//}
|
|
}
|
|
}
|
|
}
|