Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Does UnityWebRequest completely replace System.Net.WebClient?

Discussion in 'Scripting' started by zlSimon, Dec 16, 2015.

  1. zlSimon

    zlSimon

    Joined:
    Apr 11, 2013
    Posts:
    31
    I am using a lot of WebRequests (via https) with the System.Net.WebClient class which basically look like this (simplified):

    Code (csharp):
    1.  
    2. try
    3. {
    4.     result = webclient.DownloadString("someurl");
    5. }
    6. catch(WebException ex)
    7. {
    8.     result = HandleWebException(ex);
    9. }
    10.  
    Unfortunately I need to build for WebGL too, where System.Net is not available for obvious reasons.
    I am wondering if the new UnityWebRequest can do everything what the System.Net.WebClient can do as well, or are there any restriction?
    As far as I understand the UnityWebRequest only runs in the Unity Mainthread so it is probably not possible to start requests in different threads? So only using Coroutines is the way not to have the UI getting stack right?
     
  2. zlSimon

    zlSimon

    Joined:
    Apr 11, 2013
    Posts:
    31
    so is noone using it yet? How are you handling multiple webrequests in your game?
     
unityunity