I know there are 2 ways to do it. But none of them works for me.
The first way I tried is to create a gameObject and then put a cube(shape) and a canvas with Text in it. I set the position of shape, canvas(world space) and text to (0,0,0) so that they will stay together. However, Only the cube showed up. And disabling the cube still doesn't make the text display.


So I removed it and added Text Mesh to the shape and this required me to remove Mesh Filter. And now what I can see is only an empty space. Do I have any settings wrong?

You can do that with a UI Button game object and a 3D cube. The steps are as follows:
In your empty scene, create a 3D Cube.
After that, create a UI Button object.
Now that you have the button and the Canvas, drag the Canvas to become a child of the cube, like this:

Now you have to set the Canvas to World Space render mode, remove the Canvas Scaler component, and set Width = Height = 1 and all Pos = 0.
Final step, setup the Button: set Width = Height = 100, all Scale = 0.01 and Pos Z = -0.501.
Now you have a perfectly functional button that will stay attached to the front face of the cube, no matter where the cube is positioned or rotated.
You can of course add as many buttons you want, and position them to different faces of the cube (even more than one button to a single face etc.).

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With