I’m looking for the simplest solution to solve the following issue(s) (ideally free or cheap if an external package will help).
I have a game with both 2d and 3d aspects. There is a ‘bottom half’ which contains a text box and some icons that can be clicked on (imagine doom or quake).
In the center I wish to have a 3d sphere. I would like to be able to do particle effects on this sphere (pour fire, explosions, etc.) And ideally see the sphere blow up.
I have created the various 2d elements without problem (Single canvas, Main Camera in Orthographic view).
I then attempted to add a 3d sphere as a child object of my one canvas. For reasons I do not understand, it appears FAR away. Even in ‘Scene’ view I can not see it until I set the Z value to -1069.
In the game view I do not see it all, but see the ‘Blue’ background as defined in the main camera (projection Orthographic).
To recap:
-
Scene
-
Canvas
-
Sphere
-
Main Camera
Canvas → Screen Space Overlay
Sphere → Position: 0,0,-1069. W/H 100, Scale: 5,5,5
Main Camera → Position -353, -263, 0, Scale: 1,1,1, Clear Flags skybox, background color white, culling mask everything, projection orthographic.
So my questions are:
- Why can I see the sphere in Scene mode but not game mode
- Why do I need to set its Z position to -1069 ?
- Why, when I click on Main Camera, does preview show me solid white?
- What’s the best/easiest way for me to do what I wish with the sphere as descried above?
(If there is a tutorial or something to show how I can add such a 3d element into a game with a 2d overlay, I would appreciate that).
Thank you kindly!
sphere is behind the camera and you can’t see it.
And why the sphere and the camera should be the child from the canvas ? Unchild them and place somewhere at zero point (- z position for the camera(by default it is -10) . Or delete at first canvas, make your scene and add later canvas and use it only for the ui-elements(interface).
Okey, that helped! This is what I did for others who might be interested:
- Moved Main Camera to root node (sibling to Canvas)
- Deleted & Recreated Sphere in root node
- Set sphere scale to 200,200,200
- Set Z position for Sphere to +200
- Ensured camera was at -10
- I kept the main camera on Orthographic
(#4 needed if you want the 3d sphere to be entirely in front of the camera, otherwise you get interesting cross-sections).
I guess I still need to figure out why the main camera preview only shows the 3d object and not the UI elements (although they appear in Scene and Game mode).
I guess I need to also understand why Canvas render mode needs to be Screen Space - Overlay
(I’m going to guess that Camera does not display UI elements, and ‘screen space - overlay’ means ignore cameras, just stick it in front of the user’s face)?
You are not the first, who are confused with how the unity canvas is working
Double click on the canvas in the hierarchy and you can see how the canvas will be looking in the game (this big white box shows the borders from the interface). There are basically two “cameras” (ok, not really cameras) in the scene (if the canvas is in overlay mode): one is the “game camera” and the second is the “interface camera”. Place ui-objects in the “big white box” and the other objects in the “small white box”, lol 