Search Unity

Bug Buttons don't work properly when I add text

Discussion in 'UGUI & TextMesh Pro' started by Fruitfly08, Jul 15, 2022.

  1. Fruitfly08

    Fruitfly08

    Joined:
    Feb 5, 2021
    Posts:
    69
    I'm still relatively new to buttons when it comes to Unity, since I've never had a need to use them before. So, I'm not really sure how to fix what's going wrong here. You see, I'm trying to use the "highlight color" feature with the buttons so the player can tell the button is interactable more easily. And so I set the color to a darker grey (so there would be a visual difference) and that worked fine.

    But when I put a text object in front of the button, so the player can tell what it's supposed to do. It doesn't highlight the button when hovering over the text object, but it still works when you're not touching the collider for the text, but still touching the button's collider. So it seems that the text I added is blocking the collision for the button, but when I looked for a collider to disable for the text, or some other solution on other unity forums, I couldn't find anything. Would you happen to know what's going wrong here?

    Thanks in advance :]
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    602
    Is the text set as child of button. There was "working as intended feature" in <= 2021.3.5 causing mouse events to not work like UI expects its. It got fixed in 2021.3.6.

    Alternatively or if you are using different Unity version which doesn't have that fix applied yet, the setting for disabling raycast target for Textmesh pro component is in "Extra settings" category. Don't know where its' for legacy text component.
    upload_2022-7-15_23-44-44.png
     
  3. Fruitfly08

    Fruitfly08

    Joined:
    Feb 5, 2021
    Posts:
    69
    Thank you! The raycast target button fixed it :)