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

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

问题描述

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

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?

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

Has anyone any idea about this in Unity? I am using unity 5.5.2.

推荐答案

最简单的调试方法是:

  1. 在编辑器中而不是在全屏模式下运行游戏(取消选中最大化播放时"按钮)
  2. 选择场景中的 EventSystem GameObject
  3. 在检查器中,打开预览"窗口并将其设置为足够大
  4. 将鼠标移到屏幕上,检查按钮的名称是否出现在pointerEnter
  5. 字段旁边
  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. 确保按钮上方没有任何UI元素,这些元素可能会阻止射线广播
  2. 确保已对按钮使用的图像启用了射线广播(检查 RaycastTarget )

  1. 确保场景中有 EventSystem
  2. 确保在按钮上附加了回调,以触发功能
  3. 确保您没有任何 CanvasGroup Interactable设置为false
  4. 请确保您在游戏对象上附加了 GraphicRaycaster (在通常是画布)
  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天全站免登陆