UnityWebRequest.downloadHandler.data not returning correct data as byte[]
I have data for a level stored as a base64 string
One of the ways works but it turns the raw byte[] into text format with www.downloadHandler.text, then uses System.Convert.FromBase64String to transform that back into a byte[]. I'm not sure why the raw byte[] from www.downloadHandler.data isn't working. Here is my code. LoadLevel takes byte[] as a parameter.
private IEnumerator LoadLevelFromRawBytes () {
using (UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(url + fileName)) {
yield return www.Send();
if (www.isError) {
Debug.Log(www.error);
} else {
// This works. However, I don't want the string loaded into memory
LoadLevel(System.Convert.FromBase64String(www.downloadHandler.text));
// I feel like this should work but it's as if the byte[] isn't in the right format
LoadLevel(www.downloadHandler.data);
}
}
}
Your answer
Follow this Question
Related Questions
[Hololens] Connecting using Unity's UNET doesn't work after the first time connecting 1 Answer
Having multiple UNET errors that I believe are caused by unity itself. Am I doing something wrong? 1 Answer
Download Multiple Images from Server and show in unity Images 0 Answers
Convert float to byte array and read with node js 1 Answer
Network Transport Layer API does not work with iOS to PC???? 0 Answers