Unity Canvas 按钮不起作用 [英] Unity Canvas button not working

查看:96
本文介绍了Unity Canvas 按钮不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我向其中一张图像添加了一个画布组件以覆盖默认的图层顺序排序.原来那个面板上的按钮控件已经停止工作了?

有人在 Unity 中对此有任何想法吗?我使用的是统一 5.5.2.

解决方案

最简单的调试方法是:

  1. 在编辑器中运行游戏,而不是全屏(取消选中

    如果您看不到,这里有可能的解决方案:

    1. 确保按钮上方没有任何可能阻止光线投射的 UI 元素
    2. 确保您对按钮使用的图像启用了光线投射(检查

      1. 确保您的场景中有 EventSystem
      2. 确保你的按钮有一个回调,以便触发你的功能
      3. 确保您没有任何 CanvasGroupBlocksRaycastInteractable 设置为 false
      4. 确保您附加了 GraphicRaycaster在游戏对象上(通常在画布上)

      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 any idea about this in Unity? I am using unity 5.5.2.

      解决方案

      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)

      这篇关于Unity Canvas 按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆