using UnityEngine;
using System.Collections;
public class ObjectsGenerator : MonoBehaviour {
public GameObject[] gos;
// Use this for initialization
void Start () {
gos = GameObject.FindGameObjectsWithTag("Untagged");
for (int i = 0; i < gos.Length; i++) {
Debug.Log (gos);
}
}
}
Strangely enough, while gameObject.tag == “Untagged” works, GameObject.FindGameObjectsWithTag(“Untagged”) doesn’t.
You can get around by this by getting all the GameObjects in the scenes, and verify their tag.
var gameObjects = GameObject.FindObjectsOfType<GameObject>();
foreach(GameObject go in gameObjects)
{
if (go.tag == "Untagged")
{
Debug.Log (go.name);
}
}