Hi there I’m trying to get to grips with Unity and I’ve seen several Tutorials say I can drag and drop a UI.Text object from the heirarchy view to a public variable in my script component on the inspector window to ensure that the public variable has an instance at runtime
(I’m simply trying to display a score value )
the problem:
despite seeing this work in several video tutorials and doing it myself with other Gameobjects another projects whenever I drag an drop the destination field doesn’t highlight when dragging the text field over the script field and when I drop nothing happens! (it doesn’t connect )
am I doing something wrong or is this a defect or quirk in the editor …??
I’m currently blocked with this and v frustrated - any help would be much appreciated
Hi samseed1970, I encountered this same issue today(I may be a few years late, but I hope it helps someone). The problem is that you need to make the variable with type TextMeshProUGUI and not Text. If you are using TextMeshPro(or Text) texts, then this should help:
public TextMeshProUGUI myScore;
If that doesn’t work try these also(although it should have worked already :p) :
public TextMesh myScore;
public TextMeshPro myScore;
Now you will be able to drag and drop your text in the inspector. I hope this fixes the issue.