KOI3125
KOI3125

Reputation: 47

How can I get whole HTML code using Unity2D

I want to get whole HTML code to get some data from web in Unity. I checked the Unity documents, and I followed the example which is written in Unity doc. But all I can get is These Logs.

<!DOCTPYE HTML>
<html>

Is there any way to get a whole HTML Code in Unity? This is my code.

using UnityEngine;
using System.Collections;
using UnityEngine.Networking;

public class MyBehaviour : MonoBehaviour {
    void Start() {
        StartCoroutine(GetText());
    }

    IEnumerator GetText() {
        UnityWebRequest www = UnityWebRequest.Get("https://gunwoo7.github.io/My_blog/Test.html");
        yield return www.SendWebRequest();

        if(www.isNetworkError || www.isHttpError) {
            Debug.Log(www.error);
        }
        else {
            // Show results as text
            Debug.Log(www.downloadHandler.text);

            // Or retrieve results as binary data
            byte[] results = www.downloadHandler.data;
        }
    }
}

Upvotes: 1

Views: 569

Answers (1)

derHugo
derHugo

Reputation: 90724

You content is already there!

In the log Console Window Unity by default only displays the first two lines of each message.

But if you click on it you will see the complete message in the lower part of the console (Test just executes your exact code):

enter image description here


You can also adjust this and display more then the two lines (up to 10) via

enter image description here

so now you can see all (up to 10) lines at once

enter image description here

Upvotes: 1

Related Questions