FindGameObjectsWithTag returns results only within hierarchy of calling gameObject

I have the following simple validation to check if an UI pane is present in the scene:

public static bool IsMenuDialogActive()
            return GameObject.FindGameObjectsWithTag("MenuDialog").Length > 0;

And i have two UI GameObjects that call that method, ‘A’ and ‘B’, and B is a child of A. ‘A’ is an object that can have one or more ‘MenuDialog’ child objects active at a time.

If I call IsMenuDialogActive() from within ‘A’ it returns true if any of these child objects is active. But if call it from within ‘B’ it returns zero objects. I suspect that FindGameObjectsWithTag only searches for tagged objects within the hierarchy of the object that calls it. But this is not clear from the documentation for FindGameObjectsWithTag. Is this a correct assumption?

Good day.

“Is this a correct assumption?”


FindGameObjectsWithTag fins all ACTIVE objects in the scene with that tag, does not care parenting or distances, or type of object.

Bye :D! !

PS: If you create an array with this function, it will store all objects that are active in that moment. If then you setActive(false) some of the objects, it will continue inside the array.