eval for dynamicaly var's in JavaScript

Hi,

i need a solution for dynamicaly var’s

i have 28 textures with name: inhalt01 - inhalt 28

Now i will change the texture from background on click a button

GUI.Label (Rect (Screen.width/2 - 1280/2 ,Screen.height/2 -1024/2,1280,1024), eval("inhalt01"));

What is the best way? eval will not work.

What about an array, listing all those textures ?

Or Resources.Load ?

Have you tried doing this:

eval( “GUI.Label (Rect (Screen.width/2 - 1280/2 ,Screen.height/2 -1024/2,1280,1024), inhalt01 )” );

An array, though, would be a much better choice if possible.

var inhalt : Texture[ ] = new Texture[28];
GUI.Label (Rect (Screen.width/2 - 1280/2 ,Screen.height/2 -1024/2,1280,1024), inhalt[0] );

that will not work, gui requires to be called in ongui which is as well as granted with eval to be no the case

This works:

function OnGUI () {
  var test = "LOL";
  eval( "GUI.Label( Rect(0,0,100,100), test )" );
}

As it is being called in OnGUI. “LOL” pops up in the top-left of the screen.