- Home /
Question by
AhsanNaeem · Mar 29, 2017 at 02:50 PM ·
texturepath
How to pick a texture from device folder?
Hello, I'm new to Unity. I want that a png file saved in the device should be picked and set as the texture. I searched a found a suggestion shown here:
public static Texture2D LoadPNG(string filePath) {
Texture2D tex = null;
byte[] fileData;
if (File.Exists(filePath)) {
fileData = File.ReadAllBytes(filePath);
tex = new Texture2D(2, 2);
tex.LoadImage(fileData); //..this will auto-resize the texture dimensions.
}
return tex;
}
This looks great but how a path is assigned to string variable so that it selects the device folder. Thanks
Comment