Hi folks,
how to ask java to execute a String , i used to use for example in MaxScript for example :
String1 = “transform”
String2 = “position”
String3 = “[0,1,0]”
in maxscript would be :
Execute (String1+ “.” +String2 + “=” +String3);
and the result is simalar to
transform.position = [0,1,0];
how to do this in unity3d ?!
thx
UnityScript and C# are compiled languages, not interpreted, so there really isn’t any way to do that. If you can explain why you wanted to do that, someone can probably suggest an alternative approach.
thx , but its usefull to get a function to do that …
am sad
i want to create a prefab with a script that contain these varriable :
var obj : GameObject;
var component : String ;
// then my script below
what i want is , execute this line :
obj.GetComponent[component].enabled = true ;
Yes, you can, if you don’t mind the built size grown up by 1Mbyte. (In fact, I never use it in web-player :p)
eval(“Debug.Log("hello world")”);
eval(“transform.position = Vector3(1,1,1)”);
1 Like
that’s exactly what i was looking for …
Thanks !!!
Oops, I wasn’t aware UnityScript supported that. Be aware that it’s probably a lot slower than compiled code would be, but thanks apple_motion for setting the record straight 