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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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?