UI objects overlapping

I have a pool of UI objects that I am using to show name of items that are on the ground. So every time a item drops, I take one of the UI objects from the pool and place it on the item using WorldToScreenPoint. The problem I am having is that when there are a bunch of items clustered on the ground, the UI for each item overlaps. I want them to stack on top of each other if overlapping. Not sure how I can fix this issue. Here is an image of the problem.

2894098--212841--itemname.png

1 Like

You have to sort the labels.
Place the first label (that one that is the lowest on the screen or maybe nearest to the camera in world space like to normally wood.
The other you have to check if the rect that they would be displayed overlapping with any other ui element that already there.
If its overlapping move element up so that they do not overlap anymore.

One useful function is,

(This all is if you are doing you ui all in one canvas)

1 Like

Thanks for the help. I got it working.

Hey, I’m working on the same thing atm, but how did you fix this?
I’m trying with boxcolliders, but I’m getting serious performance issues.

Not really sure how you would detect if they overlap by using rect.overlaps, cause you’d need to reference each specific label.

Hey guys, Sorry to reopen this thread but I have the exacte same issue and I cant find a proper solution.
I made a thread there : Prevent overlaping of my item UI element like Diablo of PathofExile - Unity Engine - Unity Discussions