Ido Ben Shalom
Ido Ben Shalom

Reputation: 568

How to check if UI And GameObjects elements are being obscured

I want to check if a UI element is obscuring another UI element for example: when i click on the circled element [Screenshot 1] and the panel opens up [Screenshot 2] if the panel is displayed on top of the the circled element

same question about a UI element that is displayed on top of a gameobject element [Screenshot 3]

[Screenshot 1]

UI Element behind Another UI Element

[Screenshot 2]

[Panel Displayed on to of element[2]

[Screenshot 3]

Gameobject behind UI Element

Upvotes: 0

Views: 358

Answers (1)

captainCrazy
captainCrazy

Reputation: 132

You can use a raycast with the camera being the origin. This way, the first hit will be the one that is on top of everything, the second hit will be below that etc. You can traverse all the hits to determine what is on top of what.

Upvotes: 1

Related Questions