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

Problems upgrading from WWW to UnityWebRequest

Discussion in 'Scripting' started by ElnuDev, Apr 26, 2020.

  1. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    I'm having problems upgrading from
    WWW
    to
    UnityWebRequest
    . For some reason, my code is only working with
    WWW
    . What I'm doing to upgrade is replacing
    WWW www = new WWW(webURL);
    with
    UnityWebRequest www = UnityWebRequest.Get(webURL);
    and
    www.text
    with
    www.downloadHandler.text
    . Is there anything else I need to do?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,814
    Check out some examples of the newer system. It's a little different. For one you have to yield the Send() method or the SendRequest() method rather than just the www object.
     
    ElnuDev likes this.
  3. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    Thanks so much! Replacing
    yield return www;
    with
    yield return www.SendWebRequest();
    fixed the issue.
     
    Kurt-Dekker likes this.