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

How to change WWW Object AudioClip import settings?

Discussion in 'Scripting' started by LaneFox, May 20, 2014.

  1. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,381
    How do we import 2d sounds at runtime? I'm using WWW and have something working fine where it imports a file from the local hd, but the sounds come in as 3D by default and I need to toggle them to 2D.

    Use case:
    Custom folder in the program directory that users can fill with their own music to play ingame. Music needs to be a 2d sound.

    The code is basically like this:
    Code (csharp):
    1.  
    2. ....
    3. public string url;
    4. private string urlPrefix = "file://"+Application.dataPath+"/";
    5.  
    6. public void GetWww();
    7. {
    8. wwwObject = new WWW(urlPrefix+url.Value);
    9. storeAudio.Value = wwwObject.audioClip;
    10. //now magically set the clip to 2d
    11. }
    12. ...
    13.  
     
  2. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,381