Search Unity

Is there a function so users can import an image (Avatar) inside an unity build ?

Discussion in 'Editor & General Support' started by SGFX, Oct 6, 2015.

  1. SGFX

    SGFX

    Joined:
    Mar 25, 2014
    Posts:
    24
    > Thread title

    Hey guys,

    I want people to be able to load an image into my unity game to be used as their avatar.
    Is there a default unity function that allows such a thing ? Let user choose an image from their PC
    and the game uses it as texture for something ?

    Best regards,
     
  2. McMayhem

    McMayhem

    Joined:
    Aug 24, 2011
    Posts:
    443
    Are you talking about giving the player the ability to browse through their local disc/Documents directories for this image, or are you talking about having the player add an image to a folder in your game directory (like the Override/ folder in NWN) that will be loaded at run time with the game?

    The latter method is actually pretty simple. Instead of using Resources.Load, you'll be getting the image (PNG or TGA only i believe) from the StreamingAssets/ folder.
     
  3. SGFX

    SGFX

    Joined:
    Mar 25, 2014
    Posts:
    24
    The latter one, I want them to browse through their windows folders and select an image
    like imgur or any of the image hosting sites. If its a unity web build, I can not work the other way as they have no game files on their pc.
     
  4. SGFX

    SGFX

    Joined:
    Mar 25, 2014
    Posts:
    24
    Anyone an idea ?
     
  5. Dave-Carlile

    Dave-Carlile

    Joined:
    Sep 16, 2012
    Posts:
    967
    I think you mean "the former one"...

    Once you know the file it's a simple matter of loading the data and creating a Texture2D and assigning that to a material. The Texture2D documentation has an example of how to do that.

    As far as the browsing... you'll have to create that interface yourself or find an asset that does it.
     
  6. SGFX

    SGFX

    Joined:
    Mar 25, 2014
    Posts:
    24
    Makes sense, thanks.