Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Discussion "Failed to create texture from downloaded bytes" in download hander in UnityWebRequest

Discussion in 'Scripting' started by esanuriana08, Jun 3, 2023.

  1. esanuriana08

    esanuriana08

    Joined:
    Jan 10, 2021
    Posts:
    13
    I tried to load the image from the link with
    UnityWebRequestTexture.GetContent()
    then got the message "Data Processing Error, see Download Handler",
    after that I checked
    uwr.DownloadHandler.error
    I got the error "Failed to create texture from downloaded bytes".. does anyone know why?

    link image : https:// raw.githubusercontent.com/esa08/files/main/CLV_Acueducto-01.jpg
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    If that is the exact link, then you have a space after the // that probably shouldn't be there.
     
    Bunny83 likes this.
  3. esanuriana08

    esanuriana08

    Joined:
    Jan 10, 2021
    Posts:
    13
    no, in my script it doesn't add spaces... I just add spaces in description because forum failed to load the link...
     
  4. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,057
    Edit:

    After some testing, there seems to be something with the image data itself.
    If I put it into paint and re-save it as a jpg, it loads just fine.
    So something has been done to this image's data that Unity cannot process.

    You could send a bug report with the image.
    But it may just be easier to re-save the image and then upload it again.


    Used code:
    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using UnityEngine.Networking;
    4. using UnityEngine.UI;
    5.  
    6. public class TextureDownloader : MonoBehaviour
    7. {
    8.     public string Url;
    9.     public RawImage Image;
    10.  
    11.     private IEnumerator Start()
    12.     {
    13.         using var textureRequest = UnityWebRequestTexture.GetTexture(Url, false);
    14.         yield return textureRequest.SendWebRequest();
    15.  
    16.         if (textureRequest.result != UnityWebRequest.Result.Success)
    17.         {
    18.             Debug.Log(textureRequest.downloadHandler.data.Length);
    19.             Debug.LogError($"Download was not a success. {textureRequest.result}\nError: {textureRequest.error}\nDownloadHandlerError: {textureRequest.downloadHandler.error}", this);
    20.             yield break;
    21.         }
    22.      
    23.         Image.texture = DownloadHandlerTexture.GetContent(textureRequest);
    24.     }
    25. }
     
    Last edited: Jun 3, 2023
  5. esanuriana08

    esanuriana08

    Joined:
    Jan 10, 2021
    Posts:
    13
    yeah I think like you. Problem is in the image


    unfortunately the image cannot be changed because this image comes from the server entered by the user..

    Thanks for reply