[Unity] WWW v.s HttpWebRequest & HttpWebResponse



// WebRequest

HttpWebRequest request = (HttpWebRequest) WebRequest.Create( url );
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader( responseStream, Encoding.GetEncoding("utf-8") );
string text = reader.ReadToEnd();

Using WWW class in Unity is simple:

// WWW

var www = new WWW( url );
yield return www;
Debug.Log( www.text );



歡迎您留言與分享!(Welcome for comments or sharing!)

Related Post:

Tagged on: