using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class Test : MonoBehaviour
{
public IEnumerator TestCoroutine()
{
Debug.Log("TestCoroutine()");
UnityWebRequest req = UnityWebRequest.Get(firebaseHost + "/.json");
req.SetRequestHeader("Accept", "text/event-stream");
var response = req.SendWebRequest();
int bytesSoFar = 0;
while (!req.downloadHandler.isDone)
{
if (req.downloadHandler.text.Length != bytesSoFar)
{
string allText = $"Bytes: {req.downloadHandler.text.Length} : " + req.downloadHandler.text;
Debug.Log(allText);
bytesSoFar = req.downloadHandler.text.Length;
}
yield return null;
}
Debug.Log("IsDone");
Debug.Log("Final value to text: " + req.downloadHandler.text);
}
// Use this for initialization
void Start()
{
StartCoroutine(TestCoroutine());
}
}