So I want to make a game where the Player can pick up an Item when he is near it and presses F and I found the perfekt tutorial for that:
I did everything like he said in the Video but I just cant drag and drop the Text into the “Pick Up Text” Slot. I recalled all the things in the Script to match my Game but it doesnt Work. This is my first Time using the Texts so sry if I am just dumb.
Make sure you arent accidentally using TextMeshPro in your code. Newer versions of Unity will basically only have TMPro and it takes a different type than Text. It takes TextMeshProUGUI or something like that.
If you arent using TMPro, verify the object you are trying to drag and drop has a text component attached in the inspector, then verify that the field you are trying to drop it into says (Text) as well.
Ok next problem: I can drag and drop the Text into the Slot in the Inspector now and when I walk over it, I can even see that it should show but I cant see it.
Its hard to tell without having the project. Try messing around with it in the inspector. Can you move it, stretch it out, duplicate it and see that one, change the alpha, change the sorting layer, etc?? What is happening on the canvas renderer when it is visible vs not?
The only difference i see in the inspector is the material that gets added when it is invisible, the Default UI Material. Try messing around with a different one.
Try messing around with every component possible on it before you check the code (which i doubt this is a code issue, but its never out of the question)
check also that you are not trying to drag and drop your - TextMeshPro - or - TextMeshProUGUI - variable directly to your script file. One can easily click in editor the script file like - PlayerController - active, and it will show the suitable variable slot in - Inspector - (Mono Script) Import Settings - in which one can’t drag and drop anything.
You must select the actual Object in - Hierarchy - where the script (like PlayerController) is assigned to. There is the right place where the - TextMeshPro - or - TextMeshProUGUI - should be dragged to.
For anyone else stuck still, after you change your script to use TextMeshProUGUI instead of Text, you will probably have to include the namespace as well, for some reason UnityEngine.UI is not enough. Had to right click the textmesh pro component in the unity editor and then click edit script to get to the file to figure out the namespace and class name.