如:
//遍歷場景中所有物體,獲取泛型T類型物體
object[] gameObjects;
gameObjects = GameObject.FindSceneObjectsOfType(typeof(Transform));
foreach (Transform go in gameObjects)
{
if (go.GetComponent() != null)
//獲取成功,添加相關操作
}