Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug IsRaycastLocationValid calculation error in Image

Discussion in 'UGUI & TextMesh Pro' started by nickelback, Nov 11, 2023.

  1. nickelback


    Sep 14, 2020
    I am using Unity 2022.3.10f1 version, in which the version of 'com.unity.modules.ui' is 1.0.0, I have noticed that this version has been the same in the most recent Unity versions. Recently, I found a calculation issue with IsRaycastLocationValid when determining if an image can be clicked through its alpha value. This issue was not present in Unity 2018.
    The calculated x and y here should only be the sprite's own offset position. However, when querying alpha through the texture, if this texture is an atlas, then the wrong values have been used to obtain the alpha value.
    The result is bound to be incorrect. In Unity 2018, I noticed that it would take the textureRect value from the sprite once to find the position in the sprite atlas.
    Currently, I can override this method by inheriting from Image, but then we would have to use a new script to mount when editing the UI. I have tried to find ways to upgrade com.unity.modules.ui, but none have resolved this issue.
    Right now, I'm not sure if it is due to my incorrect usage, or this issue has not been resolved yet?