i want to browse a picture from a directory to be a texture of an object while in game mode

can i select a picture to be texture to an object in runtime, its like uploading a picture but its just from a local folder

What you would have to do, is create a new texture, then apply that image to that texture, and then from code, use this below to add your texture to your object, you can do this in update, or apply it in a coroutine if you wish for it to be applied if certain arguments are true/false etc…


Texture2D tex = Resources.Load("mainFolder/Textures/textureToUse") as Texture2D;


renderer.material.mainTexture = Resources.Load("mainFolder/Textures/textureToUse", Texture2D);

To do this via javascript, i would use something like this…:

var texture1 : Texture;
var texture2 : Texture;

function OnGUI () {

	GUI.Box (Rect (10,10,100,90), "Change Texture");

	if (GUI.Button (Rect (20,40,80,20), "Texture 1")) {
		renderer.material.mainTexture = Resources.Load("texture1", Texture2D);

	if (GUI.Button (Rect (20,70,80,20), "Texture 2")) {
		renderer.material.mainTexture = Resources.Load(texture2, Texture2D);

I’m hoping this works, I haven’t tested it…!!! :smiley:

You may like to check out these links!!!:

For Unity GUI Script Reference, head to: http://unity3d.com/support/documentation/ScriptReference/GUI.html

Unity GUI Basics: http://unity3d.com/support/documentation/Components/gui-Basics.html

Unity 2DTexture Reference: http://unity3d.com/support/documentation/Manual/Textures.html

Unity3D Texture Script Reference: http://unity3d.com/support/documentation/ScriptReference/Texture2D.html

comment back if u need more help…