- Home /
Multiple Cameras: why are my gizmos not rendered in the game view
Hi, I'm making a space shooter game, where my spaceship's movement is restrained within specific bounds. I draw a gizmo to visualise these bounds, and so far it worked perfectly.
But now I want to add a UI, and since my game is orthographic, but I want my UI to be in perspective, I use a camera render mode for my canvas.
Thus I created a new camera (called it "UICam", and the other is "GameCam"), set it to depth only, made sure the depth is higher than GameCam's, and the UI displays nicely, as though it was an overlay.
BUT: my gizmos are no longer rendered in the game view. I don't understand why. Since I'm in "depth only" it doesn't make any sense that the UICam overwrites the gizmos that are rendered by GameCam.
I tried to set UICam to be Orthographic, thinking maybe that would be the issue, but to no avail. Note that if I set the render mode to "Overlay" the gizmo displays just fine. I guess there's something I don't understand about how Gizmos are rendered.
Note: yes, I did enable Gizmos in the game view
To be clear, because some ppl are apparently confused, when I talk about the "game view" I'm talking about the Game Window in the editor, not in the actual final build of the game.
Here's the game window when UICam is disabled (you can see the green lines from the Gizmo being drawn)
Here's the game window when UICam is enabled (Gizmo no longer rendered)
Answer by b1gry4n · Oct 17, 2016 at 02:19 PM
Gizmos are used for debugging. They do not get built into the final game.
https://docs.unity3d.com/ScriptReference/Gizmos.html
If you want gizmos in your final build, you need to create your own solution, like THIS
Downvoting me because you werent clear in your initial question isnt the right way to get the help youre looking for, but since i am such a kind soul...
Your gizmos arent showing up in game view (in the editor) because the gizmos are drawn using the top most camera, set to perspective in your case, and the gizmos arent in the shot. Im not sure how youre creating these gizmos, but you need to make sure the top most camera (highest depth) can see them.
Notice in my screenshots how the gizmos are "offset". You most likely need to adjust the orthographic cameras "size" or the perspective cameras FOV, and guesstimate, since lining up perspective to orthographic perfectly is near impossible. The problem lies with the combination of perspective and orthographic views not lining up.
The easiest solution is to just make a 3rd camera that draws nothing, on the highest depth, and use the same settings as your orthographic camera
OTHRO UI CAM OFF:
ORTHO UI CAM ON:
I don't want to see the gizmo in the final game, I want to see the gizmo in the game view in the Unity Editor (which you absolutely can do by clicking the "Gizmo" button in the game view).
I apologize for the undeserved downvote. I thought that my question was very clear, where apparently it was not.
That idea of a 3rd camera drawing nothing is brilliant. Thanks
Your answer
Follow this Question
Related Questions
Gizmos are rendering twice 2 Answers
very flat fbx objects disappear in game view? 2 Answers
Dissable lights per camera? 2 Answers
Rendering the same Render Texture differently to separate cameras 0 Answers