Icer Exiomo
Icer Exiomo

Reputation: 49

Unity Accessing method of 3d Text/TextMesh to other script

i made a script and attached it to 3d text, now my problem is accessing the method from that script to other class

my class

the class that i want to access

Upvotes: 1

Views: 156

Answers (2)

Programmer
Programmer

Reputation: 125305

You are using FindGameObjectsWithTag with 's' in the Object. Use FindGameObjectWithTag without 's' in the Object. The version of this function with 's' is for array but g is not defined as array.

That line of code should be:

g = GameObject.FindGameObjectWithTag("tagText No");

Upvotes: 4

Sam Bauwens
Sam Bauwens

Reputation: 1367

FindGameObjectsWithTag returns an array of gameobjects (GameObject[]), and you are trying to assign it into a GameObject.

Use FindWithTag instead :

g = GameObject.FindWithTag("tagText no");

Upvotes: 2

Related Questions