I have a bunch of prefabs in the game, created at different times… How can I delete one of them when they all have the same name, or tell one to play an animation later in the game? Is there a way to create dynamic variable names? How can I differentiate between prefabs?
var I1: GameObject;
if (shape == "I1"){
var CloneI1 = Instantiate( I1, Vector3(tempX,tempY+400,-70), Quaternion.identity) as GameObject;
//CloneI1.animation.Play("grow");
}
Well this may not be the best solution might be kindof slow depending on what your doing, but you can create a “count” variable and everytime you instantiate an object then you can find the object with the name like
var I1: GameObject;
var count : int;
if (shape == “I1”){
var CloneI1 = Instantiate( I1, Vector3(tempX,tempY+400,-70), Quaternion.identity) as GameObject;
count += 1;
Clonel1.name = “Name”+count; //CloneI1.animation.Play(“grow”);
if(somethingYouWantToCallLater){
GameObject.Find(“Name”+(whatevernumberyourlookingfor))
}
I’m not an expert but i hope it helps
}