Im trying to develope a system where if i enter the name of a texture i have in my assets folder, i can create a texture2d object and apply the string name to that object and have it find and apply the image in my assets folder to it.
Where im getting stuck is, when im trying to define the Texture2D asset in my script, i cant just say something like this:
var showImage : boolean = true;
var stringForNewImageToBeDisplayed : String = "myImage"; //this string will be changing through an XML script periodically
var currentImage : Texture2D; //the Texture that im trying to update
function showImageOverlay()
{
if(showImage)
{
//where im trying to assign the name of an image i have in my asset folder
currentImage = stringForNewImageToBeDisplayed;
}
}
function OnGUI()
{
//shows image on screen
GUI.DrawTexture (Rect (Screen.width*.1, (Screen.height/2)-(((Screen.width*.8)/1.6)/2)-20, Screen.width*.8, (Screen.width*.8)/1.6), currentImage);
}
This seems like it should be pretty simple but i dont know my way around JavaScript well enough to figure it out. Am i close? Thanks very much for any tips you can give me here!