Hello
i am making some codes in c# to instantiate a Gameobject but i want to know the name or tag of the instantiated object
so i can use
if (gameobject.name == "the instantiated object")
//do something
is there anyway to do it?
Hello
i am making some codes in c# to instantiate a Gameobject but i want to know the name or tag of the instantiated object
so i can use
if (gameobject.name == "the instantiated object")
//do something
is there anyway to do it?
try this
if(gameObject.name.Equals("YourGameObject")){
//do something
}
or use tag
if(gameObject.tag.Equals("YourGameObject")){
//do something
}
I would create a temp variable that allows you to assess it instead of looking for it after the fact.
GameObject clonePrefab = Instantiate(prefabObject,transform.position,Quaternion.identety) as Gameobject
clonePrefab.name = "new object's name"
clonePrefab.tag = "objectstag"
WUCC