- Home /
3d GameObject anchored to the new UI canvas
I'm trying out the new UI system (unity 4.6 beta 17) and so far it's great!
I'm trying to create a HUD, that scales to different screen sizes, which is very easy in the new system. However I want to place a 3D-model (rotating weapon) as part of the HUD, anchored to the upperright corner using the rect transform-anchoring.
Unity seems to get unstable, when I mix the rect transform and 3D-renderer... Maybe because beta, maybe because I'm doing it wrong.
Anyways, is it possible to do what I want to achieve in some way? Any hints are very welcome :-)
First You are using a old beta version you can download the actual unity version here Download Unity or download the stable version 4.6 here Unity download archive.
The best way to use 3D objects in UI is create a Camera for the object and a RenderTexture Asset, put the render texture in the camera "Target Texture" field, in the canvas use a Raw Image component and select the RenderTexture as the Raw Image "Texture" field.
Answer by fafase · Nov 24, 2014 at 08:59 AM
Create a second canvas and make the render mode WorldSpace. Now you can use 3D models.
I have done that. I haven't changed other settings. It still does not show in game window, just only in scene editor.
Where is your canvas and where is your object? When using World Space, the canvas is now in world position so if your camera is at (0,0,0) your canvas needs to be somewhere there as well. You also need to update your canvas position so that it follows the camera.
It works! The problem now is that the 3d object intersects other object in the scene.
Remove collider, But best would be to have a second camera that you use for that purpose, then using Depth, you would render that UI camera over the world camera so that your 3D model is always on top and never interacting with the others.
This second camera would be placed somewhere far enough where nothing happens.
Answer by cregox · Nov 18, 2014 at 10:47 PM
Just create a regular UI canvas and add your 3D object inside.
Hierarchy View:
+ Canvas (Rect Transform, Canvas)
+ Panel (Rect Transform) -> this is the anchor
3D Object (Regular Transform) -> your 3D gameObject
You need to set the layer of the 3D object to UI
That doesn't work. The 3d model it's still part of the game world causing shadows and etc and doesn't not get rendered as part of the UI.
Your answer
Follow this Question
Related Questions
How to click on button that is behind transparent image in New UI? 2 Answers
Making a GUI element follow the cursor without delay. 2 Answers
New UI: How to change depth/order from script? 4 Answers
How to fix the world space canvas not showing in game 0 Answers
Canvas Graphics raycaster, prevent 2d and 3d physic raycast 0 Answers