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.
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)