Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Cant drag and drop text into Inspector!

Discussion in 'Editor & General Support' started by Media_Malte, Aug 1, 2022.

  1. Media_Malte

    Media_Malte

    Joined:
    Jul 27, 2022
    Posts:
    18
    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.
     
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,353
    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.
     
  3. Media_Malte

    Media_Malte

    Joined:
    Jul 27, 2022
    Posts:
    18
    Ah ok I didn't know that it can't be a TextMeshPro. Thank You!
     
    mouadnana2008 likes this.
  4. Media_Malte

    Media_Malte

    Joined:
    Jul 27, 2022
    Posts:
    18
    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.
     

    Attached Files:

  5. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,353
    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)
     
  6. Kentombaidoo

    Kentombaidoo

    Joined:
    Oct 19, 2022
    Posts:
    2
    I am using textmeshpro and i can;t drag it either into the slot.
    What might be the problem?
     
  7. ElitistJerk

    ElitistJerk

    Joined:
    Oct 1, 2021
    Posts:
    3
    this is a bit late to reply, but if anyone else sees this

    you need to write TextMeshProUGUI in your script, and not TextMeshPro

    i derped and had this same issue
     
    agentpainai likes this.
  8. Supernuija

    Supernuija

    Joined:
    Jun 4, 2021
    Posts:
    2
    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.