- Home /
Display Gui Button On 3d Object location
Hi guys i am trying to display buttons on my #d objects position like when i hover on a object it shows the button on its position on screen and when hover is out button should not display but i am not able to achieve it plz guys help How can i know the screen position of my object and display a GUI over it ? and i have to do it from script coz i have to change the button textures and text dynamically
Answer by RChrispy · May 05, 2016 at 09:52 AM
My first thoughts:
Raycast from the mouse into scene with camera angle.
OnCollisionStay on the 3D Object
Show WorldSpace Canvas (parented on the 3D object) when hovering else hide! (GO.setActive(bool))
Maybe this helps. ( But there should be better solutions, this is just a quick one) ;)
I did not understand the third point can you please elaborate further Thanks
Parent the UGUI component Canvas with your UI on the object you want to show the Button on. And then you can enable and disable this object via another script ( in your OnCollisionStay )
That way it is possible to hide and unhide the UI via script. And also show it in WorldSpace. (Canvas Setting).
Your answer
Follow this Question
Related Questions
Enable and disable a button selection 3 Answers
Multiple Cars not working 1 Answer
Changing a GUI Button's font in code 1 Answer
Can't create a button when clicked? 1 Answer
Making a GUI button appear after pressing another GUI button? C# 1 Answer