Ortho cam size question

hi,guys.

i have a question about ortho cam size.

if the size change,like zoom in/out(fieldOfView or orthographicSize?),Gameobjects in the scene change as well,but can i make some exception?like ,these Gameobjects have some ui objects,i dont want it change with the camera,just stay unchange,or the scene will be very weird.

how can i make that happend?is there anyways except OnGUI() can do this?

Each camera has a culling mask attribute which dictates which layers the camera renders.

For GUI, most solutions use 2 cameras with different culling masks. The game camera is set to clear to skybox / color, the culling mask is set to everything except the GUI elements and the draw depth is the lowest.

The GUI camera is layered on top, it is set to clear depth only, culling is set to UI elements and the draw depth is higher than the game camera.

Do note that using this method will always render the GUI camera on top of the game camera. If you want actual game elements remain unchanged by perspective / camera size changes, you will have to implement a method to compensate for the size changes for each element.

Also, if you’re looking to create a UI, you might want to check out NGUI ( I think they have a free version in the asset store, I might be wrong though ), or ezGUI, or some other existing GUI solution. They’re all doing pretty much the same thing you’re trying to achieve and will probably save you a few hours at the very least :slight_smile: