- Home /
Draw 2D onto a 3D surface
I'm pretty deep into a project and i'm now essentially stumped. I can't find any similar questions so I guess I must ask. How can I draw a 2D HUD essentially onto a 3D surface. I previously worked with a game called GMod which had a feature known as 3D2D. Heres an example.
https://s3.scriptfodder.com/script_media/3401c07241ddf38ae90bdfa4a58cebed.png
How can this be achieved within Unity? I'm a pretty adept coder but have always hated HUD/Graphics stuff as the maths is beyond me most of the time!
Answer by Eudaimonium · Mar 31, 2016 at 10:44 AM
You can setup your HUD and UI the normal way - build a Canvas, assign it a camera etc.
Have the camera output to a RenderTarget instead of screen.
Then simply assign the RenderTarget as a Texture on the material of In-game object.
http://docs.unity3d.com/Manual/class-RenderTexture.html
As to actual interaction with the HUD on the object itself, that's going to be a bit tricky and more specific to your project. It's possible to obtain a raycast hit point on the object, re-calculate how that translates to Canvas HUD and apply the click action there, but it'll require some tinkering.
Answer by Jason_ioosh · Mar 31, 2016 at 04:12 PM
Hi @strideynet,
I had a similar problem to you this morning, and what I did was simply adding a canvas component to the gameObject where I wanna display my HUD.
I'm not really an adept coder, so there might be some other ways or methods which I'm unaware of.
But using this method, I was able to control what UI elements appear on the gameObject itself, though I'm unsure how much of a performance hog this method would be.
Cheers, Jason
Your answer
Follow this Question
Related Questions
Render a camera multiple times in a single frame? 1 Answer
Raycast trail renderer? 3 Answers
why is my Gun Model Only rendering the front bit when the animations are on? 2 Answers
Problem with open world games 3 Answers
Why isn't my gun showing up when I play in maximised mode? (Mechanim Animator) 1 Answer