Detect when a gameObject created previously is destroyed

Hi!

I have an issue trying to check when a gameObject is created, and when destoyed.
I want that only 3 bullets can be created in the scene at the same time. So if there are 3 bullets in the scene, the player can’t shoot. But the problem appears here. How can I check when one of that bullets is destroyed? When it is destroyed, the variable that controls the amount of bullets available should add 1. I have already done all that mechanics, but I can’t control when the bullet I created is destroyed.

Thank you!

How about a little script on your bullets with an OnDestroy() method that calls a static method on your main class to increase the available bullet count?
(“Static” only to make it easier to get access to it)