- Home /
How can i find out how much element on scene now?
For example i have on first scene 5 GameObjects with tag "star", but in second scene i will have 7 GameObjects with tag "star". How i can find out how much this objects in current scene?
Also i have amounth or stars and when character die i need to revive not only character i need to revive all stars too, how can i do this???
Answer by HarshadK · Jan 14, 2015 at 01:59 PM
GameObject.FindGameObjectsWithTag
EDIT:
Based on the new edit in the question.
Use GameObject.FindGameObjectsWithTag to find all the game objects within the scene.
Store their positions in an array or list.
After the player dies instantiate the star game objects at the places present in that array or list.
You can use object pooling to avoid instantiating game objects so that instead of deleting your stars just push them into pool and then again get them from pool when you need to place them back in.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to get all GameObjects in Scene? 7 Answers
Distribute terrain in zones 3 Answers
Find objects only viewable within mask 0 Answers
Click handling at world scene level 1 Answer