延迟问题解决
This commit is contained in:
1 parent
9a545f00f4
commit
609e4dc367
23 files changed
+858
-446
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -10,10 +11,23 @@ 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(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void Application_logMessageReceived(string condition, string stackTrace, LogType type)
|
||||
@@ -48,5 +62,21 @@ namespace Assets.Scripts.Scenes
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1308,9 +1308,11 @@ public class LoginController : BaseScene
|
||||
Utils.showToast(gameObject, res.errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
//Debug.Log($"{phone.isFocused}, ${pwd != null}, ${Input.GetKeyDown(KeyCode.Tab)}");
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
{
|
||||
|
||||
@@ -117,8 +117,9 @@ public class MainController : BaseScene
|
||||
float t = 1f;
|
||||
float scanTicks = 0;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (App.canvasWidth != transform.GetComponent<RectTransform>().sizeDelta.x)
|
||||
{
|
||||
App.canvasWidth = transform.GetComponent<RectTransform>().sizeDelta.x;
|
||||
|
||||
@@ -220,8 +220,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
float timer = 1f;
|
||||
bool clearLock = false;
|
||||
private void Update()
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
//CamControl();
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
if (competitionId == 0 && singleUIManager != null)
|
||||
|
||||
Reference in new issue
Block a user