What is the best way to draw a straight line between a 3D model and a GUI button? For example, let’s say I have a GUI button that corresponds to a character’s leg. If I want to draw a line between the button and the character’s leg (so a certain point in a 3D model), how can I do that? The GUI button in question essentially draws a texture, which is set in a GUI Style.
I’ve been doing some research and it seems Line Renderer might be the way to go, but I am not sure.
Any ideas how to do this?
Sure you can use a line renderer. Or you could use a stretched plane mesh. You can do it any number of ways. I guess your question is more about the specifics of how to do it?
You could do it all in canvas space by calculating the canvas space position of your world space point. Or you could do it in world space by first calculating the world space position of your UI element. That’s the basics of it anyway.
You can use GetWorldCorners to get the world space position of the UI element. Here’s some info on converting from world space to canvas space.
Sam