hi i created the 4*4 cube array and set the name to that object. when i click the object, how can i destroy the object using that name. my code is
for(var j= 0;j<30;j=j+10){
for(var i=0;i<30;i=i+10)
{
pos = Vector3(i,j,0);
var Bloc = Random.Range(1,5);
arrayLoc[Co1,Co] = Bloc;
Cube = Instantiate(prefab,pos,Quaternion.identity);
Cube.name = "name," + Co1 + Co;
Co++;
if(Co==4)
{
Co=0;
Co1++;
}
yield;
}
}
In the above code have no errors and works perfectly.
In the another script i have to destroy the particular object like var t=2; var h=3; Destroy(name,t.ToString()+h.ToString());
it does not destroy the object. It gives the error in "string does not valid" but