FindObjectsOfType<T>(true)
Some examples:
//Inactive
{
Rigidbody[] arr = GameObject.FindObjectsOfType<Rigidbody>();
}
//Active and Inactive
{
Rigidbody[] arr = GameObject.FindObjectsOfType<Rigidbody>(true);
}
//Only Inactive
{
//with "using System.Linq"
{
Rigidbody[] arr = GameObject.FindObjectsOfType<Rigidbody>(true).Where(sr => !sr.gameObject.activeInHierarchy).ToArray();
}
//Without System.Linq
{
Rigidbody[] allObjects = GameObject.FindObjectsOfType<Rigidbody>(true);
List<Rigidbody> inactiveObjects = new List<Rigidbody>(allObjects.Length);
for (int i = 0; i < allObjects.Length; i++)
{
if(!allObjects[i].gameobject.activeInHierarchy)
{
inactiveObjects.Add(allObjects[i]);
}
}
}
}