0
\$\begingroup\$

I have been working on a UI Inventory System for my Unity game and for some reason, none of my buttons work in my game. All the buttons have the ‘interact-able’ box ticked and an EventSystem which is in the scene. In my scene, I have an image, which is holding two buttons, in a canvas. The buttons are supposed initiate a function called UseItem when clicked, but they don't respond to anything. I have tested them using Debug.Log, but I don't get any messages back in the Console. I also don't get any errors or warnings. I am using Unity 2019.4.17f1 LTS. The pictures below show my UI.

Here's a picture of my game scene:

Here's the complete hierarchy:

These are the EventSystem's configurations:

These are my canvas settings:

And these are use and drop button settings:

\$\endgroup\$
7
  • \$\begingroup\$ I have some questions, 1) Can you share your canvas and it's related settings ? 2) Did you log your method "UseItem" and you are sure that it is not getting called ? \$\endgroup\$ Jan 11, 2021 at 10:13
  • \$\begingroup\$ @ÇağatayIŞIK Ok, I updated the question. \$\endgroup\$ Jan 11, 2021 at 13:43
  • \$\begingroup\$ Hmm, i would test if any button that i create in that canvas are working or not so maybe you can simply create a default button in your canvas, run your game and just click to see if that button is clickable or not, if it is clickable that your other buttons have something on top of them that prevents from clicking, if default button also not clickable it can be about sorting order of your canvas. \$\endgroup\$ Jan 11, 2021 at 13:47
  • \$\begingroup\$ @ÇağatayIŞIK I checked, and it seems to be the sorting layers, because the test button worked. Do you know how to make my buttons override all other UI? \$\endgroup\$ Jan 11, 2021 at 15:05
  • \$\begingroup\$ Try increasing the number in your canvas setting called "Sort Order", or maybe something is in front of your UI so it is blocking the buttons. You can go through every image,buttons etc and just disable their raycast target box and only leave out buttons as enabled. \$\endgroup\$ Jan 11, 2021 at 15:25

1 Answer 1

0
\$\begingroup\$

Ok, I fixed my problem. All I had to do was turn off Raycast Target for all my other inventory UI elements.

\$\endgroup\$
1
  • \$\begingroup\$ For next time: Select the EvenSystem object in the hierarchy, then try to click on your button. If another UI element is blocking the button, you'll see it in the Current Raycast and Pointer Enter properties. \$\endgroup\$
    – Sinenomen
    Jan 11, 2021 at 18:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .