Check out example codes for "unity find inactive gameobject". It will help you in understanding the concepts better.
Code Example 1
public static GameObject FindInActiveObject(string name)
{
Transform[] objs = Resources.FindObjectsOfTypeAll<Transform>() as Transform[];
for (int i = 0; i < objs.Length; i++)
{
if (objs[i].hideFlags == HideFlags.None)
{
if (objs[i].name == name)
{
return objs[i].gameObject;
}
}
}
return null;
}
Code Example 2
/// Use this method to get all loaded objects of some type, including inactive objects.
/// This is an alternative to Resources.FindObjectsOfTypeAll (returns project assets, including prefabs), and GameObject.FindObjectsOfTypeAll (deprecated).
public static List<T> FindObjectsOfTypeAll<T>() {
List<T> results = new List<T>();
for(int i = 0; i< SceneManager.sceneCount; i++) {
var s = SceneManager.GetSceneAt(i);
if (s.isLoaded) {
var allGameObjects = s.GetRootGameObjects();
for (int j = 0; j < allGameObjects.Length; j++) {
var go = allGameObjects[j];
results.AddRange(go.GetComponentsInChildren<T>(true));
}
}
}
return results;
}
Learn ReactJs, React Native from akashmittal.com