I am trying to get the component of an inactive gameobject. The gameobject that I want to get the component of is a child object. All other child objects also have the same component. But I only want to get the component of the inactive gameobject. I have tried tagging the inactive gameobject and finding the tag and getting its component. But GetComponent does not get the component of an inactive gameobject.
GetComponent does get components from inactive gameobjects. However FindWithTag (like most Find methods) does not find inactive gameobjects. Note that there is no FindGameObjectWirhTag method, just a FindGameObjectsWithTag which however returns an array of gameobjects and not a single one. Though even that will not find inactive gameobjects as you can read in the documentation.
Inactive gameobjects do not participate in any activities in your scene. The only way to actually “find” inactive gameobject is through Resources.FindObjectsOfTypeAll.
You should generally avoid using any of those Find methods. It’s generally better to setup references beforehand in the inspector.