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

Other UnityWebRequestTexture seems to be missing

Discussion in 'Scripting' started by BlueHK, Sep 12, 2023.

  1. BlueHK

    BlueHK

    Joined:
    Feb 4, 2022
    Posts:
    6
    Unity 2021.3.20

    On my work computer, which is a Mac, I'm working on the texture download code which should just be simply this.

    Code (CSharp):
    1. using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture("textureLocation"))
    However, the UnityWebRequestTexture is throwing an error and doesn't seem to exist.
    upload_2023-9-12_12-21-13.png

    I then checked my home computer, which is running windows and the UnityWebRequestTexture is showing up fine there for the same version of Unity.

    I even double checked the docs to make sure it didn't get removed or deprecated.
    https://docs.unity3d.com/2021.3/Doc...orking.UnityWebRequestTexture.GetTexture.html

    Anybody know why this wouldn't show up on the mac vs the windows computer? I didn't see anything else odd when I tried the same code in VS on Windows.

    Thanks for any help provided!
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,526
    So you checked the docs and the example and you have added the
    using UnityEngine.Networking;
    at the top like shown in the example, right? Maybe have a second look at the documentation of the static class itself.
    Of course, like always, instead of a using statement you could do
    Code (CSharp):
    1.     using (UnityWebRequest uwr = UnityEngine.Networking.UnityWebRequestTexture.GetTexture("textureLocation"))
    2.  
    instead. This static method is just a simple wrapper around an ordinary UnityWebRequest with a DownloadHandlerTexture as download handler. Both are in the
    UnityEngine.Networking
    namespace.
     
  3. BlueHK

    BlueHK

    Joined:
    Feb 4, 2022
    Posts:
    6
    Correct, UnityWebRequest is in the networking library. In my screenshot, the UnityWebRequestTexture is not showing up. This is on my work mac.

    I even, just to make sure I wasn't having dead brain cells, copied and pasted the example they have in the docs as well as other examples I found online.

    I can do the exact same thing on my personal home computer running windows and the UnityWebRequestTexture shows up. Using the same Unity version.

    As per this screenshot, UnityWebRequest is green, but the UnityWebRequestTexture is throwing an error of does not exist in current context.
    upload_2023-9-13_12-5-37.png

    The part that is confusing me is why this is happening on the mac but not my windows pc.