Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Networking UnityWebRequest improvements

Discussion in '5.2 Beta' started by bdovaz, Aug 1, 2015.

  1. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    I've played some time with the new API and I have the following problems/improvements:

    1 - Problems reporting download progress: I tried to download a simple JPG with the following code and I see values like 0, 0.997655, 0.7487621, 0.8035932, 0.689096... With no sense at all.

    Code (CSharp):
    1. IEnumerator Test() {
    2.         UnityWebRequest request = UnityWebRequest.Get(Url);
    3.  
    4.         request.Send();
    5.  
    6.         while (!request.isDone) {
    7.             Debug.Log(request.downloadProgress);
    8.  
    9.             yield return null;
    10.         }
    11.  
    12.         Debug.Log("DONE");
    13.     }

    2 - Allow to select texture format: In WWW you could instantiate a Texture with a custom format (DXT1, DXT5, RGB24, ARGB32...)

    http://docs.unity3d.com/ScriptReference/WWW.LoadImageIntoTexture.html

    But with this simple API it's not possible:

    Code (CSharp):
    1. UnityWebRequest request = UnityWebRequest.GetTexture(uri);
    2.  
    3. Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
    3 - Expose specialized handlers for "AudioClip" and "MovieTexture": I saw in google docs this text:

    "A Specialized Download Handler for Audio Clips will also be available by launch."

    But there is no mention to MovieTexture class.

    Also there should also be allowed to stream audio and video like with WWW class.

    4 - Expose a method using generics to cast handlers: Now we have to do this that it's not really clean code:

    Code (CSharp):
    1. Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
    For example:

    Code (CSharp):
    1. Texture2D texture = request.GetHandler<DownloadHandlerTexture>().texture;
     
  2. Alex-Lian

    Alex-Lian

    Guest

    Feedback appreciated and passed along to the dev. Looking at fixing #1 in 5.2 if possible. The rest are being taken as feedback, but unlikely to hit during this cycle.