Search Unity

Bug Wrong button clicked when user input happens at same frame that GameObject added to scene

Discussion in 'UGUI & TextMesh Pro' started by LesBloom, May 16, 2023.

  1. LesBloom

    LesBloom

    Joined:
    Feb 2, 2017
    Posts:
    167
    Hello,

    I am encountering what I think is a Unity bug.

    I have a few overlapping Unity Ui Buttons. They are all interactable and all using a Unity Ui Image with Raycast Target set to true.

    I find that if I try to click the top-most button, at the exact same frame when a new, different Unity Ui GameObject is added to my scene hierarchy, then the bottom-most button receives the input instead of the top -most button.

    Has anyone else encountered this?

    I was able to bandaid a single scenario by tracking and checking how many frames it's been since I added a GameObject, but it's hardly full proof. It only works for this one button and only for the tracked GameObject being added.

    Maybe a better bandaid solution could be offered? (While waiting for the proper solution that is).

    Thank you, in advance, for your time and assistance. I appreciate it.