- Home /
How to position a GUI-Element relative to a game object?
So I'm getting started developing a little game in Unity, and I'd like to make it so that if I click on a character on screen, a menu pops up next to the character with possible actions.
I have messed around a bit with several options: GUILayout, GUI, UI with Canvas. I haven't tried just making gameobjects looking like such a menu and manipulating those, yet. I can position the menu the way I want to by using GUI (with new Rect(gameobject.x+offset etc.)), but not using GUILayout or the canvas-based UI.
Now, I could just use GUI, but everyone seems to warn against that, and it's called Legacy in Unity's documentation. So I hesitate before committing to that choice.
It's starting to look to me that I should probably "fake" the UI using gameobjects, because everything else is either very cumbersome or actively discouraged.
What is the optimal or at least the idiomatic way of doing something like this?
Your answer
Follow this Question
Related Questions
Make children of a Layout Group fit their respective sizes (confusing docs) 1 Answer
Help with GUILayout and tooltip(C#) 1 Answer
How to make a simple gui list 0 Answers
Make GUILayout horizontal first, then vertical? (C#) 3 Answers
Why Does IsPointerOverGameObject Not Work with GUILayout Controls? 0 Answers