I’m trying to find objects with a certain tag, but this:
GameObject[] rootElements = GameObject.FindGameObjectsWithTag("UIRootElement");
isn’t working for some reason. The objects definitely exist with the correct tag, but it just never finds anything.
Running this code:
var allObjects = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[]; // grab all gameobjects
foreach (GameObject obj in allObjects) {
if (obj.tag == "Untagged") continue;
if (obj.CompareTag("UIRootElement"))
Debug.LogError(obj.name);
}
finds my 2 GameObjects with the correct tag, but I don’t think this is a very good solution and I’d like to know why GameObject.FindGameObjectsWithTag isn’t working.