Unity3d:UI显示网络延迟

本文介绍了一个使用Unity实现的实时网络Ping监测系统。通过创建一个名为PingTest的MonoBehaviour类,该系统能够定期向指定的IP地址发送Ping请求,并在NGUI的UILabel上显示延迟数据。此外,系统还根据Ping值的不同范围改变UILabel的颜色,以直观地反映网络状况。
  1. public class PintTest : MonoBehaviour {
  2.     public string ip = string.Empty;//IP地址
  3.     Ping ping;//Ping命令
  4.     string label;//延迟数据
  5.     public UILabel pingLabel;//NGUI label
  6.     void Start()
  7.     {
  8.         ip = "61.135.169.121";    // 百度
  9.         SendPing();
  10.     }
  11.     private bool iswork = false;//是否有网络通信
  12.     void Update()
  13.     {
  14.         if (Application.internetReachability == NetworkReachability.NotReachable)//没有网络
  15.         {
  16.             label = "500";
  17.             SetColor(5000);
  18.             ping
行 277185: 11-11 18:25:47.324061 16995 17231 W Unity : DontDestroyOnLoad only works for root GameObjects or components on root GameObjects. 行 277561: 11-11 18:25:47.914532 16995 17710 E Unity : -------- GLSL link error: The number of vertex shader storage blocks (1) is greater than the maximum number allowed (0). 行 277936: 11-11 18:25:48.832760 16995 17711 W Unity : The referenced script (CustomCubeMip) on this Behaviour is missing! 行 277943: 11-11 18:25:48.841515 16995 17711 W Unity : The referenced script on this Behaviour (Game Object '!ftraceLightmaps') is missing! 行 277946: 11-11 18:25:48.841781 16995 17711 W Unity : The referenced script on this Behaviour (Game Object 'combinecube') is missing! 行 277978: 11-11 18:25:48.901343 16995 17231 W Unity : Particle System is trying to spawn on a mesh with zero surface area 行 278701: 11-11 18:25:50.442267 16995 17231 I Unity : Default clip could not be found in attached animations list. 行 279609: 11-11 18:25:52.305336 16995 17231 I Unity : ALog2019-2.01.0052.07-eLogBattle-jishuai-[Next2025] strategyID 4 not find in Next2025Config 行 279832: 11-11 18:25:52.836090 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 279854: 11-11 18:25:52.837523 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 279876: 11-11 18:25:52.839913 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 279899: 11-11 18:25:52.841155 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 279922: 11-11 18:25:52.843595 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 279944: 11-11 18:25:52.844802 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 279967: 11-11 18:25:52.847697 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 279991: 11-11 18:25:52.848928 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280014: 11-11 18:25:52.851305 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280036: 11-11 18:25:52.852514 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280059: 11-11 18:25:52.854913 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280082: 11-11 18:25:52.856141 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280106: 11-11 18:25:52.860700 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280128: 11-11 18:25:52.861933 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280151: 11-11 18:25:52.864219 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280173: 11-11 18:25:52.865444 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280196: 11-11 18:25:52.867845 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280218: 11-11 18:25:52.869131 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280241: 11-11 18:25:52.871468 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280263: 11-11 18:25:52.872769 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280288: 11-11 18:25:52.875152 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280310: 11-11 18:25:52.876290 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280333: 11-11 18:25:52.878866 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280355: 11-11 18:25:52.879882 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280380: 11-11 18:25:52.884141 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280403: 11-11 18:25:52.885338 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280426: 11-11 18:25:52.887457 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280449: 11-11 18:25:52.888444 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280472: 11-11 18:25:52.890603 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280494: 11-11 18:25:52.891612 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280516: 11-11 18:25:52.894305 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280542: 11-11 18:25:52.900280 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280564: 11-11 18:25:52.902652 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280586: 11-11 18:25:52.903663 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280609: 11-11 18:25:52.905926 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280631: 11-11 18:25:52.907128 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280667: 11-11 18:25:52.942162 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_HeadIcon02.unity3d 行 280691: 11-11 18:25:52.943137 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_HeadIcon02.unity3d'. 行 280715: 11-11 18:25:52.944505 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_HeadIcon02.unity3d 行 280739: 11-11 18:25:52.945491 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_HeadIcon02.unity3d'. 行 280764: 11-11 18:25:52.946874 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_HeadIcon02.unity3d 行 280788: 11-11 18:25:52.947936 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_HeadIcon02.unity3d'. 行 280812: 11-11 18:25:52.949334 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_HeadIcon02.unity3d 行 280835: 11-11 18:25:52.950378 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_HeadIcon02.unity3d'.
最新发布
11-14
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值