FindObjectsOfType on OnDisable not finding the GameObjects

Hi guys, I have a weird behavior happening when I change to another scene.

In OnDisable I use FindObjectsOfType to search for the object that have Card attached,
but some times he don’t find anything. :frowning:

Not sure why, I see that the components are there, but sometimes he find, sometimes not.

Anyone knows what can be?

    private void OnDisable()
        foreach (Card card in FindObjectsOfType<Card>())

        Debug.Log("COUNT: " + list.Count);

Hey there,

Not sure on how your setup looks like but since you mention that you are changing scene i assume that the “card” objects are not tagged with don’t destroy on load and thus sometimes get disabled/destroyed before your OnDisable has a chance to find them.
Disabling and destruction of objects is not subject to a given queue or order as far as i know.
Perhaps you could create a workaround to search for the card objects just right before you give the command to change the scene. This way you can be sure that all objects are still present and that the definite next thing to happen will be the change of scenes.

Hope this helps.