Trouble with GameObject.FindObjectsOfType

Hello everyone, I’m having an issue where GameObject.FindObjectsOfType returns as !null even when no objects of that type exist in the scene.

In Detail:

As used in the script below, even when no objects of the type being searched for exist, somehow the result of the search is never null. I’ve used this type of approach before and have not had this issue.

Any ideas on why this is happening are appreciated.

	//needed because UI elements exists before the data they need to work with:
	private IEnumerator GetReferences()
	{
		Debug.Log("GetReferences() coroutine started");

		while(GameObject.FindObjectsOfType<Ship_Module_Master>() == null)
		{
			Debug.Log("UI_GridSizer GetReference() still needs references");
			yield return null;
		}

		Debug.Log("GameObject.FindObjectsOfType<Ship_Module_Master>() has returned !null");
		
		//now, find the player master module:
		ship_Module_MasterArray = GameObject.FindObjectsOfType<Ship_Module_Master>();
		for(int counter = 0; counter < ship_Module_MasterArray.Length; counter++)
		{
			if(ship_Module_MasterArray[counter].shipControlledBy == ShipControlledBy.Player)
			{
				Debug.Log ("playerShip_Module_Master reference found");
				playerShip_Module_Master = ship_Module_MasterArray[counter];
				moduleCounter += 2; //hull and engine...
			}
		}
		
		//now, use Player master module to find number of gun modules on the player's ship:
		ship_Module_GunArray = playerShip_Module_Master.GetComponentsInChildren<Ship_Module_Gun>();
		UI_Repair.ui_Repair.PlayerShip_Module_GunArray = ship_Module_GunArray;
		for(int counter = 0; counter < ship_Module_GunArray.Length; counter++)
		{
			Debug.Log("adding 1 gun module to UI");
			moduleCounter += 1;
		}
		
		InstantiateModuleBoxes();
		SizeAndSortGrid();
	}

It appears to always return an array object. That array object can be of length zero.

Maybe something like:

GameObject.FindObjectsOfType<Ship_Module_Master>().Length != 0