- Home /
How Can I Create Buttons In World Space and NOT Screen Space
From my understanding unity can provide basic GUI functionality with its built in features, however I need to have buttons that aren't flat against the screen and are actually attached to an object. I am creating a first person restaurant management game and the player can select a variety of functions from a screen attached to their counter. Much like when you go to burger king or McDonalds and the cashier takes your order on a touchscreen in front of them. How can I achieve this?
Are you asking about a 3d user interface or just positioning the 2d GUI elements above/on objects in 3d space?
That's a tough question but from what I Googled it seems like a 3d user interface would be what I'm looking for.
You can't achieve that with the standard UI library. You will need to find something on the asset store or make your own.
The third-party packages NGUI and EZGUI will make your job creating buttons and other interfaces in world space easier. The do cost a bit of money though. Here is a showcase video for EZGUI.
http://www.anbsoft.com/content/ezgui/ez_gui_showcase/index.html
It is rumored that Unity's long promised new interface classes will be based on NGUI, so if it has the features you need, that would be the way to go. I use EZGUI, but NGUI did not exist when I made that choice.
Answer by byerdelen · Mar 23, 2014 at 09:52 AM
camera.WorldToScreenPoint would work up to a point. The targets world point will be translated to the screen point so it will be like it is attached to the target.
http://docs.unity3d.com/Documentation/ScriptReference/Camera.WorldToScreenPoint.html
Answer by Owen-Reynolds · Mar 23, 2014 at 04:37 PM
For true world text, use 3dText (TextMesh in the code, but 3DText from the drag down.) Put the text entirely in world-space. If you put one on the side of a cube, it will like it's really written there. Only weird thing is it shows through everything (such a solid objects in front of it.) There are fixes here involving shaders (paste-in code.)
May as well use 3D models for the buttons.
For the check, raycasts seem the most versatile. The standard "what in the world is my mouse over?"
For comparison, using WorldToScreen and GUIText, as byerdelan suggests will have unchanging size and never rotated. Will look more like a computer is adding labels to a picture. Which might be easier to use and realistic enough.
The question was about GUI buttons and other such functionality, which goes way beyond simple clickable text. Actual 3d GUI libraries would be much more appropriate for the job (and also much faster) ;)
The question was about simulating buttons which "aren't flat" on the employee-end of a modern cash register. The replies are about GUI buttons!
If the OP really wants fully 3D buttons, looking and acting exactly like the real thing, they'll probably have to make it themselves, using 3DText and background planes. Tools the wonderful people at Unity have thoughtfully provided for us to do this.
The comments are steering towards "do you really need full 3D? Wouldn't a straight-on cash-register-view work as well?" And I agree. The only reason to go to the trouble of real 3D is if you want to simulate glancing down at the resister, or looking over at Hal's register, or maybe see your fingers (maybe showing the thumb tapping TO GO?)
Your answer
![](https://koobas.hobune.stream/wayback/20220613140943im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Main menu help needed (C#) 2 Answers
Putting Dictionary/List using foreach as buttons in a scroll view? 3 Answers
GUI Display Help 0 Answers