{"id":1192,"date":"2017-07-18T11:42:49","date_gmt":"2017-07-18T03:42:49","guid":{"rendered":"http:\/\/39.100.100.179\/?p=1192"},"modified":"2017-07-18T17:49:46","modified_gmt":"2017-07-18T09:49:46","slug":"%e6%98%be%e7%a4%ba%e7%bd%91%e7%bb%9c%e5%bb%b6%e8%bf%9f%e7%8a%b6%e5%86%b5","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=1192","title":{"rendered":"\u663e\u793a\u7f51\u7edc\u5ef6\u8fdf\u72b6\u51b5"},"content":{"rendered":"<p>\u4eca\u5929\u6211\u4eec\u6765\u5b9e\u73b0\u663e\u793a\u7f51\u7edc\u5ef6\u8fdf\u7684\u529f\u80fd\uff0c\u6709\u70b9\u7c7b\u4f3c\u738b\u8005\u8363\u8000\u91cc\u7684\u5ef6\u8fdf<\/p>\n<p>\u5f80\u5f80\u5ef6\u8fdf\u8d85\u8fc7200\u65f6\uff0c\u73a9\u5bb6\u5c31\u4f1a\u77e5\u6653\u5f53\u524d\u7f51\u7edc\u72b6\u51b5\u5dee\uff0c\u5f71\u54cd\u6e38\u620f\u4f53\u9a8c<\/p>\n<p><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2017\/07\/149625271110.jpeg\" data-lightbox=\"image_lg\"><img title=\"\u663e\u793a\u7f51\u7edc\u5ef6\u8fdf\u72b6\u51b5 - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u663e\u793a\u7f51\u7edc\u5ef6\u8fdf\u72b6\u51b5 - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"size-full wp-image-1194 aligncenter\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2017\/07\/149625271110.jpeg\" width=\"640\" height=\"361\" srcset=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2017\/07\/149625271110.jpeg 640w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2017\/07\/149625271110-300x169.jpeg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2017\/07\/QQ\u622a\u56fe20170718113707.png\" data-lightbox=\"image_lg\"><img title=\"\u663e\u793a\u7f51\u7edc\u5ef6\u8fdf\u72b6\u51b5 - \u7b2c2\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u663e\u793a\u7f51\u7edc\u5ef6\u8fdf\u72b6\u51b5 - \u7b2c2\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"size-full wp-image-1193 aligncenter\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2017\/07\/QQ\u622a\u56fe20170718113707.png\" width=\"457\" height=\"163\" srcset=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2017\/07\/QQ\u622a\u56fe20170718113707.png 457w, http:\/\/www.u3d8.com\/wp-content\/uploads\/2017\/07\/QQ\u622a\u56fe20170718113707-300x107.png 300w\" sizes=\"(max-width: 457px) 100vw, 457px\" \/><\/a><\/p>\n<pre class=\"lang:c# decode:true \">using UnityEngine;\r\n\r\nnamespace Utils\r\n{\r\n    public class PingUtil : MonoBehaviour\r\n    {\r\n        public string ip = string.Empty;\r\n        Ping ping;\r\n        string label;\r\n        GUIStyle guiStyle;\r\n\r\n        void Start()\r\n        {\r\n            ip = \"121.42.114.17\";    \/\/ \u8fd9\u91cc\u6211\u7528\u7684\u662f\u6211\u7f51\u7ad9\u7684ip(www.u3d8.com)  \u9700\u8981\u66ff\u6362\u6210\u81ea\u5df1\u7684\u670d\u52a1\u5668ip\r\n\r\n            SendPing();\r\n\r\n            guiStyle = new GUIStyle();\r\n            guiStyle.normal.background = null;\r\n            guiStyle.fontSize = 40;\r\n\r\n        }\r\n\r\n        bool isNetWorkLose = false;\r\n        void OnGUI()\r\n        {\r\n            if (Application.internetReachability == NetworkReachability.NotReachable)\r\n            {\r\n                label = \"460\";\r\n                SetColor(460);\r\n                isNetWorkLose = true;\r\n            }\r\n            else if (isNetWorkLose || (null != ping &amp;&amp; ping.isDone))\r\n            {\r\n                isNetWorkLose = false;\r\n                label = ping.time.ToString();\r\n                SetColor(ping.time);\r\n                ping.DestroyPing();\r\n                ping = null;\r\n                Invoke(\"SendPing\", 1);\/\/\u6bcf\u79d2Ping\u4e00\u6b21\r\n            }\r\n\r\n            GUI.Label(new Rect(10, 50, 200, 50), \"ping:\" + label + \"ms\", guiStyle);\r\n        }\r\n        void SendPing()\r\n        {\r\n            ping = new Ping(ip);\r\n        }\r\n\r\n        \/\/\/ &lt;summary&gt;\r\n        \/\/\/ \u4eff\u738b\u8005\u8363\u8000\u5ef6\u8fdf\u8fc7\u9ad8\uff0c\u989c\u8272\u53d8\u5316\r\n        \/\/\/ &lt;\/summary&gt;\r\n        \/\/\/ &lt;param name=\"pingValue\"&gt;&lt;\/param&gt;\r\n        void SetColor(int pingValue)\r\n        {\r\n            if (pingValue &lt; 100)\r\n            {\r\n                guiStyle.normal.textColor = new Color(0, 1, 0);\r\n            }\r\n            else if (pingValue &lt; 200)\r\n            {\r\n                guiStyle.normal.textColor = new Color(1, 1, 0);\r\n            }\r\n            else\r\n            {\r\n                guiStyle.normal.textColor = new Color(1, 0, 0);\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u6211\u4eec\u6765\u5b9e\u73b0\u663e\u793a\u7f51\u7edc\u5ef6\u8fdf\u7684\u529f\u80fd\uff0c\u6709\u70b9\u7c7b\u4f3c\u738b\u8005\u8363\u8000\u91cc\u7684\u5ef6\u8fdf \u5f80\u5f80\u5ef6\u8fdf\u8d85\u8fc7200\u65f6 &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=1192\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23],"tags":[268,269],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1192"}],"collection":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1192"}],"version-history":[{"count":2,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1192\/revisions"}],"predecessor-version":[{"id":1197,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/1192\/revisions\/1197"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1192"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}