I’m trying to do a screen to select the characters in Crossy road style, so not a separate stage , but a canvas above my world in transparency.
like this:
I have created a canvas with render mode: “screen-space camera” with a scrool rect inside, then I attached my 3D objects to buttons inside the scroll rect in a panel.
The solution seems to work , but I have two problems :
For renderizare the canvas above all other objects I set the plane distance of the camera to a negative value
The canvas in overlay mode are still rendered above , one solution would be to disable them , but I do not know if it is the best solution
How can I solve my problem ? my approach is correct or there are easier ways to render 3D objects in a canvas or simulate a 3D with 2D ? ( Taking into account that I have the free version of Unity and animations on my 3d objects )
hi, I’m not sure what the problem is exactly, couldn’t quite get the point you were trying to make. Do you mean that 3d objects won’t sort with UI Panels like the cube on the left side in image ? Or is it something else?
I apologize if I was not clear enough … I’m trying to recreate the character selection in Crossy road style window.
To do that I need to use my 3d objects with a component Scroll Rect in a Canvas.
I don’t think you need to have RectTransform on 3D objects (I might be wrong) I think I’ve tested that at some point. Remember that if you parent 3D objects to canvas items, their scale will be adjusted according to canvas scale in two ways:
Scale of world space canvas → remember, that scaling canvas in xy might “look” OK but you have to transform the space also in z, otherwise 3D object rotations under canvas will be wonky. UI items are flat by nature, so it’s not so obvious that this is needed.
Canvas has a sort of “internal” scaling that is different depending on settings I think. By default you might see, that if you parent a 3D object under a panel for example, it’s scale with compensate and shows something like 50,50,50.
Anyhow, I’ve only tested this earlier like I mentioned above and IIRC, it worked, however I never went further with it. You should be able to parent, align and rotate objects, they’ll move with scrollRects and so on. So think of them as 3D objects stuck to panels, don’t expect them to do anything else than transform with panels :).
EDIT:
now that I re-read what you wrote… “The canvas in overlay mode are still rendered above” - so the issue is somehow related to some issue with layering/render order of canvases?
More or less, I solved the problem by disabling the canvas in overlay mode when needed and setting the plane distance of the camera to -200.
Now everything is working properly and I got what I needed, I just wanted to know if this is a good solution or not.
Nope in Unity 5 you can use RenderTextures in the free version. it was different in 4.X. I personally think its easier to use the RenderTexture with RawImage as darkhog suggested. Though it is possibly by use a screen space -camera canvas and changing the plane distance.