By using the same mechanic as the lifetime hooks (#2), and keeping track of when an element moves, it's possible to add and remove an element from a spatial hash.
This can make overlap checks significantly faster.
UI doesn't tend to change a whole lot every frame, so the performance benefit will probably outweigh the cost of maintaining a spatial hash for complex UI's. For simple UI's it is not necessary.
I propose using a spatial hash is opt-in per scene:
By using the same mechanic as the lifetime hooks (#2), and keeping track of when an element moves, it's possible to add and remove an element from a spatial hash. This can make overlap checks significantly faster. UI doesn't tend to change a whole lot every frame, so the performance benefit will probably outweigh the cost of maintaining a spatial hash for complex UI's. For simple UI's it is not necessary.
I propose using a spatial hash is opt-in per scene: