The question is answered, right answer was accepted
cannot find UI GameObject by script
Hi there. I has a problem: Unity can't found UI object by this example script:
public GameObject objToFindUI;
void Start()
{
objToFindUI = GameObject.FindWithTag("toFind");
}
What am I doing wrong? (FindGameObjectWithTag too didn't work)
Are you sure the gameObject to find is active in the scene?
Are you sure the object is tagged
toFind
(notToFind
norTOFIND
)?Are you sure this script is attached to an active gameobject?
Answer by tormentoarmagedoom · Jul 18, 2018 at 12:21 PM
Good day.
First:
Is
GameObject.FindObjectWithTag()
Not
GameObject.FindWithTag()
SEcond:
Check what Hellium commented you :D
Bye!
UnityEngine.GameObject' does not contain a definition for `FindObjectWithTag'
I think I never find UI object with one script by this way... But I found another method: just create objectScript with only "public GameObject toFind", add it to empty obj with "tag1" and in first script:
objToFindUI.GetComponent().toFind.GetComponent().***
and this works