how to know in code the number of instances a prefab made?

how to know in code the number of instances a prefab made? [without counting(incrementing) by the instantiate and decrementing by the destroy methods, because more than 1 script needs to instantiate an instance of the same prefab and it will be a big job to use counting]

[without counting(incrementing) by the instantiate and decrementing by the destroy methods, because more than 1 script needs to instantiate an instance of the same prefab and it will be a big job to use counting]

Why would it be a big job? Just put it in a Start() { } on the gameobject that you instantiated. Then it doesn’t matter where the gameobject was instantiated from because the incremination happens on the first frame of the gameobject itself exsisting

Basically just

// Put this on the gameobject you need the amount of
public class thisClass : MonoBehaviour
{
    void Start()
    {
        amount++; // amount is a variable on a different gameobject's script (the one that needs the amount)
    }

    private void OnDestroy()
    {
        amount--;
    }
}

This does not need its own script if you are using this stuff elsewhere btw