How to use more than one camera for screen space camera?
Hello,
I want to use two cameras for the Screen Space Camera for my Canvas... how do I do that? So far it can only add one camera, but I need two cameras as I've made a 1st and 3rd person view mode, that I want to use the same HUD/UI.
Hi, can you explain in a bit more detail what you want to do?
Well, I've two cams (one for 1st and another for 3rd person view) but I can only attach one cam to the Screen Space Camera for the Canvas I'm using for my HUD.
I need a way to add both cameras to that so that I don't have to make a new HUD for each camera. But I don't know how to go about doing that... so far the only solution to me seems like I've to make a HUD for the 1st person cam and one for the 3rd person cam (separately). But I would really like to avoid this, and ins$$anonymous$$d be able to use the same HUD for both.
Any suggestions?
Ok, so you have sth like a splitscreen and wan to have the canvas displayed in both halfs?
not a splitscreen... a switch... surely you must have played some games where you can switch between first person and third person views?
but yes, i want the same HUD to be displayed in both, I can do this by putting the canvas outside of the player (not making it a child off) but that results in a cluster fuck of gameobjects, so i would really like a way to still make it work when it's a child of the player... but because "Screen Space Camera" only allows me to put one camera in there, i don't know how to make this happen :/
Ok, I am not sure how you organized your scene, but I don't think your HUD should be a child of the player. I don't understand what you mean by this : "that results in a cluster fuck of gameobjects".
By default, when you create a UI object in your canevas, its layer is "UI Layer". And if your camera has "UI Layer" checked in its culling mask, so your UI will be displayed. The position of your camera in your hierachy is totally independant of the position of your canevas. You can have 50 different cameras in your scene that have 50 unique behaviour, and still they are all able to display the unique canevas (at the root of your hierarchy) in the same way.
I don't understand your problem, if your screen is split like sacee asked, you really should precise it in your question. All what your canevas elements are displayed in the "UI layer". So if your cameras both display UI layers elements, your HUD should be displayed no matter which camera is active.
if i use "Screen Space Camera" then i can only apply one cam, and because i'm using two cams (1st and 3rd) then i can't use that option.
so what can i do ins$$anonymous$$d?
all i can do so far is either to:
1 make a HUD for each cam, since Screen Space Camera only allows me to add one cam.
2 put the HUD outside of the player, which i really want to avoid as i want to keep the HUD as a child of the player
PS. i'm not so sure why this is so hard to understand... i've said the same thing several times now in different ways :/
I'm not sure what kind of a UI we are talking about here, but you could use a 3rd camera to render the HUD while toggling between the other two or rendering them both. Use the Dont clear flag on it and you're good to go.
that sounds like a terrible way of doing it... surely it must be possible to put the Canvas/HUD inside the player gameobject as a child and still make it work?
This would be really strange that you have to do this. I have a big project where I need to use 4 different cameras and I never had any problem to display my HUD. I don't understand in what way 1st or 3rd camera would make any difference. Really need to test something myself to help you on this.
Are you absolutely sure that both your camera have 'Eveything' set in their Culling $$anonymous$$ask ?
Your answer
Follow this Question
Related Questions
Sprite in Canvas not projected correctly in Maximum playmode 0 Answers
Unity UI does not visible when i drag using canvas set to screen space - camera 1 Answer
Canvas not rendered by camera 1 Answer
UI Mask strange behaviour on world space canvas 0 Answers
Get the relative dimensions of two different canvases 0 Answers