0
\$\begingroup\$

I'm working on a birds-eye-view for our Unity3D game world, where each point of interest has a label hovering above it. The problem is that sometimes they overlap, although there is more than enough space on the screen for them to co-exist.

Can anybody think of a better way to separate them than checking every texture with every other texture and moving them away from each other?

\$\endgroup\$
3
\$\begingroup\$

I managed to do it this way:

  • Put all gui elements in a list.
  • sort them from bottom to top on their Y coordinate
  • loop through them in this order, if one collides with a previous one, move it up as much as necessary and go to the next.

this way you'll get a neat stack of GUI-labels (names of game objects in my case) and they'll never overlap.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.