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???



Based on the new edit in the question.

  1. Use GameObject.FindGameObjectsWithTag to find all the game objects within the scene.
  2. Store their positions in an array or list.
  3. After the player dies instantiate the star game objects at the places present in that array or list.
  4. 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.