- Home /
how to load images from hard disk to gui buttons?
hi. i've been digging this out for about 1 week but i haven't get a result: how to load some images from some folder in player's hard drive to gui buttons automatically? consider that the folder and the images' names are predefined. i just want to load images to buttons so that user can use them as a material to an object in game. is there any way except using "for" to create the buttons automatically in OnGUI function? cuase it wont let the built game run! giving "crash" error... help me plz.
Answer by DaveA · Apr 27, 2011 at 09:20 PM
Assuming this is a stand-alone game you can use the WWW object with file:// prepended to the path to load a texture. Do it in a Start routine, not OnGUI
var myGUItexture : Texture;
function Start() { www : WWW = new WWW ("file://path/filename.jpg"); yield www; myGUItexture = www.texture; }
function OnGUI() { if (GUI.Button (Rect (10,10,50,20), myGUItexture)) do something }
ok, so how to put those images on buttons? how should the user choose the image? if i dont put it in OnGUI then i cant use it :(
Your answer
Follow this Question
Related Questions
how to load images automatically from user's hard disk? 1 Answer
How To Change a Image When Press Button Click? 0 Answers
How to load images from given folder? 7 Answers
Loading screen freezes as soon as I begin loading a scene additively? 1 Answer
Fatal error after loading image and drawing texture 1 Answer