fairygui / FairyGUI-unity

A flexible UI framework for Unity
https://fairygui.com
MIT License
2.68k stars 636 forks source link

Avoid hitting test on invalid positions #227

Closed davyzhang closed 4 months ago

davyzhang commented 4 months ago

Screen position out of view frustum (screen pos -nan(ind), -nan(ind), 0.000000) (Camera rect 0 0 1536 2048)

PR: https://github.com/fairygui/FairyGUI-unity/pull/226

xiaoguzhu commented 4 months ago

the pos comes from Input.mousePosition or Mouse.current.position.ReadValue(), I've never come across a situation where they weren't numbers or were infinite, can you explain?

davyzhang commented 4 months ago

unity 版本 2022.3.30f1.git.7361922 Revision: 2022.3/staging 70558241b701 Built: Tue, 14 May 2024 21:12:45 GMT

其实就是样例场景, 我把我加的那几行注释掉了就会不停的报错 Example 01 / Example 03 都可以重现

image image

问题可能出在这一行

image

没有用新的inputSystem 这里拿到的确实是nan

davyzhang commented 4 months ago

如果我用了新的input system, 按钮点击又会全部失效, 所有按钮都不能点击了

image

这个地方在new input system下面一直都是0 image

xiaoguzhu commented 4 months ago

在网上没有找到资料说明在什么情况下Input.mousePosition出现infinite的值,我自己也没能重现,也没见其他人反馈过。你试试换个unity版本,看看是不是特定Unity版本的bug。

davyzhang commented 4 months ago

那我先close把, 你后面再观察一下