Search Unity

Alternative to WWW ?

Discussion in 'Scripting' started by Freddy888, Oct 20, 2014.

  1. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    165
    I did a lot of digging but didn't find much that helped directly.

    I am trying to load web based WAV files asynchronously because every time I request a WAV file Unity hangs.

    I tried using threading but the debugger tells me WWW can only be called in the main thread.

    Is WWW the only way for Unity to communicate over the web ?

    How about if I wrote a DLL to handle the http requests, would that be possible ?

    Or are there other solutions please ?

    Many thanks.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    There are .NET classes to achieve this (I haven't used any of them, but HttpWebRequest exists), but I think your bigger challenge will probably be to then get the WAV file imported as a Unity audio file.
     
  3. atrakeur

    atrakeur

    Joined:
    Jun 14, 2011
    Posts:
    134
    Are you using your WWW object in a coroutine? I don't think you need anything near a dedicated thread just to load some files asynchronously.

    By the way, even when loading in another thread, you'll need to use the unity thread to import the file into unity. So it'll hang at that point without a coroutine.
     
    Freddy888 likes this.
  4. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    165