Unity Canvas button not working

后端 未结 2 1095
情书的邮戳
情书的邮戳 2021-01-01 02:00

I added a canvas component to one of my images to override default layer order sorting. Turns out the button controls on that panel have stopped working?

Has anyone

相关标签:
2条回答
  • 2021-01-01 02:18

    The easiest way to debug is to :

    1. Run the game in the editor, not in full screen (uncheck Maximize On Play button)
    2. Select the EventSystem GameObject of your scene
    3. In the inspector, open the Preview Window and make it big enough
    4. Move your mouse on your screen, and check if the name of your buttons appear next to the field pointerEnter

    If you can't see it, here are possible solutions :

    1. Make sure you don't have any UI elements above your button which could block the raycasts
    2. Make sure you have enabled raycasting on the images used by your buttons (check RaycastTarget)

    1. Make sure you have an EventSystem in your scene
    2. Make sure you have a callback attached to your buttons so as to trigger your functions
    3. Make sure you don't have any CanvasGroup with BlocksRaycast or Interactable set to false
    4. Make sure you have a GraphicRaycaster attached on a gameobject (on the Canvas usually)
    0 讨论(0)
  • 2021-01-01 02:31

    Turns out I did not know that you have add a Graphic Raycaster component as well. Started taking input after that.

    Thanks everyone.

    0 讨论(0)
提交回复
热议问题