延迟问题解决
This commit is contained in:
1 parent
9a545f00f4
commit
609e4dc367
23 files changed
+858
-446
No files matched your search
@@ -107,5 +107,7 @@ namespace Assets.Scripts.Apis.Models
|
||||
public string AltitudeGraph { get; set; }
|
||||
//0,0,0
|
||||
public string Camera { get; set; }
|
||||
public string MineCountString { get; set; }
|
||||
public int MineCount { get; set; }
|
||||
}
|
||||
}
|
||||
+1
-25
@@ -15,7 +15,7 @@ using System.Timers;
|
||||
|
||||
public static class App
|
||||
{
|
||||
public static string Host = "http://192.168.0.101:5084/";
|
||||
public static string Host = "http://192.168.0.101:5085/";
|
||||
|
||||
public static string AppVersion = Application.version;
|
||||
|
||||
@@ -119,30 +119,6 @@ public static class App
|
||||
App._IsRowerMode = bool.Parse(isRower);
|
||||
}
|
||||
Screen.sleepTimeout = SleepTimeout.NeverSleep;
|
||||
Task.Run(() =>
|
||||
{
|
||||
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
|
||||
System.Timers.Timer timer = new System.Timers.Timer();
|
||||
timer.Interval = 1000;
|
||||
timer.AutoReset = true;
|
||||
timer.Elapsed += new ElapsedEventHandler((o, e) =>
|
||||
{
|
||||
var reply = ping.Send("47.97.84.8");
|
||||
if (reply.Status == System.Net.NetworkInformation.IPStatus.Success)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
App.delayTime = new System.Random().Next(300);
|
||||
#else
|
||||
App.delayTime = reply.RoundtripTime;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
App.delayTime = -1;
|
||||
}
|
||||
});
|
||||
timer.Start();
|
||||
});
|
||||
Debug.Log(SystemInfo.deviceUniqueIdentifier);
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -99,6 +99,8 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
|
||||
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||
|
||||
transform.Find("IdContainer/Text").GetComponent<Text>().text = $"#{myMap.Id}";
|
||||
transform.Find("TimesContainer").gameObject.SetActive(myMap.MineCount > 0);
|
||||
transform.Find("TimesContainer/Text").GetComponent<Text>().text = myMap.MineCountString;
|
||||
transform.Find("Hot").gameObject.SetActive(myMap.IsFire);
|
||||
var props = transform.Find("Props");
|
||||
props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString(myMap.Distance>1000? "#0" : "#0.00")}KM";
|
||||
|
||||
@@ -1035,7 +1035,7 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
|
||||
Confirm3 confirm3 = null;
|
||||
|
||||
|
||||
public static async void InitNow()
|
||||
{
|
||||
var now = await ConfigHelper.userApi.GetNow();
|
||||
|
||||
Reference in new issue
Block a user