{"id":161,"date":"2015-04-28T15:12:55","date_gmt":"2015-04-28T07:12:55","guid":{"rendered":"http:\/\/qxu1606620110.my3w.com\/?p=161"},"modified":"2016-10-11T09:33:59","modified_gmt":"2016-10-11T01:33:59","slug":"www%e7%b1%bb%e7%bd%91%e7%bb%9c%e6%95%b0%e6%8d%ae%e5%ba%93%e4%bc%a0%e8%be%93","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=161","title":{"rendered":"WWW\u7c7b\u7f51\u7edc\u6570\u636e\u5e93\u4f20\u8f93"},"content":{"rendered":"<p>\u4ece\u7f51\u7edc\u4e0a\u83b7\u53d6\u4e00\u4e2a\u56fe\u7247 \u5e76\u663e\u793a\u51fa\u6765<\/p>\n<pre class=\"lang:c# decode:true \" title=\"\u4ece\u7f51\u7edc\u4e0a\u83b7\u53d6\u4e00\u4e2a\u56fe\u7247 \u5e76\u663e\u793a\u51fa\u6765\" >using UnityEngine;\r\nusing System.Collections;\r\npublic class WebDatabase : MonoBehaviour {\r\n\tTexture img;    \/\/ \u7528\u4e8e\u4fdd\u5b58\u7f51\u7edc\u4e0b\u8f7d\u7684\u56fe\u7247\r\n\tstring url;        \/\/ \u7528\u4e8e\u5b58\u50a8\u7f51\u7edc\u56fe\u7247\u7684\u94fe\u63a5\r\n\t\/\/ Use this for initialization\r\n\tvoid Start () {\r\n\t\turl = \"https:\/\/www.baidu.com\/img\/bdlogo.png\";\r\n\t\t\/\/ \u5f00\u59cb\u6267\u884c LoadImg \u534f\u540c\u65b9\u6cd5\r\n\t\tStartCoroutine (\"LoadImg\", url);\r\n\t}\r\n\t\/\/ 1. WWW \u4eceWeb\u670d\u52a1\u5668\u83b7\u53d6\u56fe\u7247\u8d44\u6e90\r\n\t\/\/ \u534f\u7a0b \u591a\u7ebf\u7a0b   \u4e00\u822c\u7528\u4e8e\u82b1\u65f6\u95f4\u7684\u4e8b\u60c5\u4e0a\r\n\tIEnumerator LoadImg (string img_url){\r\n\t\t\/\/ \u5b9e\u4f8b\u5316WWW\u7c7b\u5bf9\u8c61\r\n\t\tWWW www = new WWW (url);\r\n\t\t\/\/ \u7b49\u5f85\u56fe\u7247\u8d44\u6e90\u4e0b\u8f7d\u5b8c\u6bd5 yield \u7b49\u5f85\u5b8c\u6bd5\r\n\t\tyield return www;\r\n\t\timg = www.texture;\r\n\t\t\/\/ www.LoadImageIntoTexture (img);\r\n\t}\r\n\t\/\/ \u5f53img\u4e0d\u4e3a\u7a7a\u65f6\uff0c\u5219\u663e\u793a\u56fe\u7247\r\n\tvoid OnGUI (){\r\n\t\tif (img != null){\r\n\t\t\tGUILayout.Label (img);\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p>\u4ece\u7f51\u4e0a\u4e0b\u8f7dXML\u6570\u636e\uff0c\u5e76\u663e\u793a\u5143\u7d20<\/p>\n<pre class=\"lang:c# decode:true \" title=\"\u4ece\u7f51\u4e0a\u4e0b\u8f7dXML\u6570\u636e\uff0c\u5e76\u663e\u793a\u5143\u7d20\" >using UnityEngine;\r\nusing System.Collections;\r\nusing System.Xml;\r\npublic class WebDatabase : MonoBehaviour {\r\n\tstring xml = \"\";\r\n\tstring url;\r\n\tvoid Start (){\r\n\t\turl = \"http:\/\/www.duzixi.com\/sortgame.php\";\r\n\t\tStartCoroutine (LoadText ());\r\n\t}\r\n\tWWW www;\r\n\tIEnumerator LoadText (){\r\n\t\twww = new WWW(url);\r\n\t\tyield return www;\r\n\t\txml = www.text;\r\n\t}\r\n\tvoid OnGUI (){\r\n\t\tif (xml != \"\"){\r\n\t\t\tXmlDocument xmlDoc = new XmlDocument ();\r\n\t\t\txmlDoc.LoadXml (xml);\r\n\t\t\t\/\/ \u65b0\u5efa\u4e00\u4e2a\u5143\u7d20\u6765\u50a8\u5b58\u6839\u8282\u70b9\r\n\t\t\tXmlElement root = xmlDoc.SelectSingleNode (\"chart\") as XmlElement;\r\n\t\t\t\/\/ \u65b0\u5efa\u8282\u70b9\u5217\u8868\u6765\u4fdd\u5b58 \u6839\u8282\u70b9\u7684\u6240\u6709\u8282\u70b9\r\n\t\t\tXmlNodeList list = root.ChildNodes;\r\n\t\t\t\/\/ \u904d\u5386\u8282\u70b9\u5217\u8868\uff0c\u5e76\u8f93\u51fa\u6bcf\u4e2a\u5b50\u8282\u70b9\r\n\t\t\tfor (int i = 0; i &lt; list.Count; i++) {\r\n\t\t\t\tGUILayout.Box (list[0].InnerXml);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p>POST\u65b9\u6cd5\u63d0\u4ea4\u6570\u636e<\/p>\n<pre class=\"lang:c# decode:true \" title=\"POST\u65b9\u6cd5\u63d0\u4ea4\u6570\u636e\" >using UnityEngine;\r\nusing System.Collections;\r\npublic class PostScore : MonoBehaviour {\r\n\t\/\/ Use this for initialization\r\n\tvoid Start () {\r\n\t\tStartCoroutine (\"LoadTextPost\", \"http:\/\/www.duzixi.com\/stealth.php\");\r\n\t}\r\n\tIEnumerator LoadTextPost (string url){\r\n\t\t\/\/ \u5b9e\u4f8b\u5316\u8868\u5355\u5bf9\u8c61\r\n\t\tWWWForm form = new WWWForm();\r\n\t\t\/\/ \u5411\u8868\u5355\u4e2d\u6dfb\u52a0\u952e\u503c\u5bf9 \uff08\u6dfb\u52a0\u6570\u636e\uff09\r\n\t\tform.AddField (\"nickname\", \"postTest\");\r\n\t\tform.AddField (\"score\", \"1234\");\r\n\t\t\r\n\t\t\/\/ \u63d0\u4ea4\u8868\u5355\r\n\t\tWWW www = new WWW (url,form);\r\n\t\tyield return www;\r\n\t\t\/\/ \u670d\u52a1\u5668\u8fd4\u56de\u6570\u636e\r\n\t\tDebug.Log (www.text);\r\n\t}\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u7f51\u7edc\u4e0a\u83b7\u53d6\u4e00\u4e2a\u56fe\u7247 \u5e76\u663e\u793a\u51fa\u6765 using UnityEngine; usin &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=161\">\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":[21],"tags":[135,136],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/161"}],"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=161"}],"version-history":[{"count":3,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions"}],"predecessor-version":[{"id":750,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions\/750"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}