I’ve been looking for this seemingly mundane thing for HOURS now, and maybe it’s because it’s 8AM here (did overnight)… but I cannot find any answer to the problem: I just want to trace some parameters on screen (for performance testing on mobile).
So I made a GUIText object in the editor. And I tried to reference it from the GameObject’s script that manages the parameters I want to display.
I’ve found several answers saying to reference a GUIText like any GameObject (get the object with GameObject.Find(“name”)…)
The problem is that a GUIText object doesn’t inherit from GameObject! So the above doesn’t work for a GUI element (or, when I try to cast the compiler tells me that I cannot convert the type ‘GameObject’ into ‘GUIText’)
I’ve also found a few other answers that tell about assigning the GUIText to a public variable of the other object’s script in the inspector. But one can only assign prefabs, not instance objects, to public variables in the inspector (and obviously, altering prefabs params at run-time does nothing on instances)
I feel really confused because posters often seemed to find the answers useful… However for me, they don’t work, and thinking about it, it (unfortunately) makes sense.
Does someone have a definitive answer?