I want to draw a little menu above an object when it is selected, such that the bottom of the menu is at the top of the object. I have no trouble finding the top of the object, but I need to offset from there depending on the number of options visible on the menu.
My first thought was to just go through the options, figure out the visibility, sum each CalcSize(), then start over and begin adding controls from the top.
However, I’d like to avoid repeating the visibility tests, so I thought I could put the visible ones in a temporary list.
Anyway, that seems like a lot of trouble (going through the options twice, temp list, etc). Performance probably won’t be affected with the number of options I am likely to see, but I’m wondering if there is an easier or cleaner way.
Is there a way to either: move the controls after adding them to the Area (e.g. by adjusting the Area’s Rect), or have GUILayout add the controls “upwards”? (e.g. if I went through the options backwards and stacked them on top of each other). I thought maybe I could translate the GUI.matrix, but I think that will only affect the controls I draw after modifying it, so I’m left with the same problem (the amount to move it is not known until after going through them).
I guess I’ll get cracking on the original way (I’d probably be done by now ) but I figured I’d ask for future reference.
Thanks!