How to get the tags of objects if they aren't in the scene?
I know you usually get the tags at the beginning of the game because it is much less expensive to run. However, how do you deal with getting their tag names if they aren't in the scene when the game starts and without having to get them in the update? Could I make an arraylist inside of a coroutine where every time an object enters the scene, the routine is ran and it gets the name of the tag and stores it in the array list? Or is there actually a way to get the tag names in start without the objects being present?
It would help to understand why you feel the need to have a list of tags before an object enters the scene (I am assu$$anonymous$$g the objects in question are instantiated objects - otherwise they would already be in the scene and you could get this information at startup).
Also, are you looking for particular tags? All information you can provide so I can better answer your question would be appreciated.
Yes, they are being instantiated into the scene. I'm trying to create a tetris game, if that helps a bit, and I want to make it to where when the rows are destroyed that the particular colors have a break effect, such as particles of the same color. I would use OnDestroy(), but the thing is, the things being destroyed are children. So, the idea was to get the tag of the parent, based on the tag a particle system matching its color would be chosen, then when the children of that parent are destroyed, the particles would be instantiated where they stand, their vector. But, I need the tags and for efficiency, I need them when the game starts or get them one by one as the pieces are instantiated. Does this help? @$$anonymous$$avina
Still not getting what you are looking to do here. I understand your comment but I do not know you need the tag. I am assu$$anonymous$$g that you are using prefabs for each of the Tetris objects that you instantiate.
If this is the case I am going to further assume that you have a script attached to the different Tetris prefab objects. Could you not then add a particle system prefab to the script and then instantiate it in the OnDestroy()
function?
No, because the prefab is a parent, the children are what are being destroyed and the script is on the parent. Unless there is a way to use OnDestroy()
with the children from the parent, that I'm apparently oblivious to.