Search Unity

Can't display image from webpage

Discussion in 'Documentation' started by Iznhou, Sep 29, 2017.

  1. Iznhou

    Iznhou

    Joined:
    Sep 29, 2017
    Posts:
    2
    Hello, I'm a new member so I'm sorry if this is in the wrong place(I first had this in the general support section, but I'm starting to think it was in the wrong place).

    I've been working with and learning about Unity for the past few months now and I've been making good progress so far along with a book titled "Unity in Action".

    Right now, I'm learning about connecting my game to the internet and I'm trying to download an image from a webpage and display it onto a 3D cube I flattened to act like a billboard.

    Unfortunately, even though it seems like I did everything right according to my text, I keep getting a NullReferenceException. Now my experience with programming is telling me that this exception is being thrown because it's trying to reference something that's empty or isn't currently existing but I still can't figure out the problem.

    I've the code separated into different scripts named as different managers to communicate with each other. I was orignally going to upload the scripts using the code tags but since there are multiple scripts I thought I'd save time and provide links to the scripts.

    Here's the script called NetworkService; This code takes requests from other scripts using coroutines and the script sends the HTTP reponse back from what ever other script made the request:

    https://ideone.com/ycnuyH

    As you can see, one of its abilities is that it's supposed to retrieve image information from a webpage. While trying to debug, I made sure that the URL was right and it was when I pasted it into my browser.

    The next script is ImagesManager; this script actually sends a request to the first script:

    https://ideone.com/qhIJNb

    This script is also a part of another script that keeps track of all of the other manager scripts:

    https://ideone.com/ZcH2Za

    Lastly, is the code that's actually supposed to display the image and it's attached to the 3D object in the scene that's supposed to display the image. This is where the exception is coming from. Specifically at line 9:

    https://ideone.com/jl8g4s

    What could I be doing wrong?
     
  2. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287