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

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,

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.

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.

Anyone an idea ?

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.

Makes sense, thanks.