- Home /
Render a 3D object in a 2D UI Panel
Is there any way to put a 3D object inside a 2D UI? I want an object that is rotating, doesn't cast shadows, is visible regardless of scene lighting and (importantly) doesn't require any trick that involves adding a second camera as this slows down my game too much on mobile devices.
Answer by Thaun_ · Sep 24, 2017 at 05:17 PM
This is how i did it: make sure your Canvas is set to
Screen Space - Camera
and set your main camera in it. Then add your Object to the Canvas, just like you would do to any object. And then make sure the object is infront of the canvas.
One of the problems with Screenspace camera is that the postprocessing stack on the main camera is ran on the cameras that are rendered bellow it. So, any postprocessing will be applied to the UI layers underneath.
One way to solve that problem is having an independent scene with all UI and add to your game with the option additive, when loading the UI. That will solve of having tons of UI elements in every scene you have.
Answer by Drakon0168 · Dec 09, 2016 at 06:18 AM
I would make a separate camera for the object put the object in a new layer and set the main camera's culling mask to everything except that new layer then set your new camera's culling mask to only see that layer. Then you can just angle the camera to look at whatever object is in that layer and position it however you want. make sure the object doesn't have any colliders otherwise game objects will still be able to collide with it. As for the shadows and lights that would all be in the mesh renderer component of the object. You can just turn lights, shadows and other effects on or off from there.
As I said in the question, I don't want to use additional cameras because they slow the game down too much on mobile devices.
Answer by elenzil · Dec 09, 2016 at 12:19 AM
Set up the canvas to be Camera-Space, not Screen-Space. It's fairly straight-forward after that.
place your 3d object inside the ui.
with set as Camera-Space, the canvas behaves like a plane parenting to the camera in the 3d world. so all you need to do is parenting your 3d objects to that canvas
to make it no shadow, you have to set it in those mesh renderer
yep. as SunnyChow said. just set up UI panels how you like, have one of them be an empty RectTransform (eg, add a "panel" object and delete the Image component) that's just for holding your 3D model.
you might need to fiddle with the z-position of the model and UI elements to get things to layer correctly. eg, so your model is in front of the background UI elements, and behind foreground UI elements (if any).
Answer by Jayachandra205 · Apr 15, 2020 at 08:47 AM
Upon scan target Image, I have to show the 3D Animation Model along with Information in Text format. In this case I am trying to use the UI-->Panel to display 3D Animation along with Text information but 3D Animation model is not displaying and not working as expected n run time.
Could anyone guide me the right approach.
Cheers
Your answer

Follow this Question
Related Questions
Grid Layout Group leaking outside canvas. 1 Answer
Canvas shrinks over time 0 Answers
Gathering GameObjects and then creating a button for each GameObject?? 2 Answers
Can't re-enable a gameobject 1 Answer
Masking GameObject in Canvas 1 Answer