- Home /
variable inside prefab
hello,
how to insert a variable (myVariable) in prefab?
for (var i : int = 0;i < numDots; i++) {
var dot : Transform;
dot = Instantiate (prefab, Vector3(xx, yy, 0), Quaternion.identity);
dot.myVariable = i;
}
This unfortunately does not work ;(
Thank you for your help, Tim
Comment
Best Answer
Answer by Eric5h5 · Oct 30, 2010 at 07:48 AM
Use GetComponent to refer to the script attached to the instantiated prefab. The prefab has no property called "myVariable"; that would only be in a script.