- Home /
make camera background cull everything
I attached a screen shot of my game running at a resolution where theres extra space at the top and bottom. How do i make it so that anywhere the camera background is exposed, it will render above any gameobject? Really not sure how to accomplish this considering my background texture has to be above the background camera, but all the objects i want to cull are above the background texture so how can i make them go behind the camera background...
Hi could you not just add some black border objects that are placed above the height of the objects you want to hide?
ah yes i forgot to mention that since i'm publishing to iphone and android, there could be different size borders depending on the aspect ratio, both on the vertical and horizontal sides.
I know i can technically cover all the different aspect ratio and create black border objects for each one, and then at the start of the scene deter$$anonymous$$e what aspect ratio the game is running at and enable the proper border objects....
but i wanted to check if theres a simpler solution...
It does not matter if your border goes off the side of the screen, so just make each border big enough to make sure that everything is covered regardless of the aspect ratio.
not sure what you mean, depending on the resolution i may have to cover less or more because of how the background texture fits into the screen.
For example: at 480x854 FWVGA resolution you get the screenshot i posted. at 320x480 HVGA resolution you get no black bars on the top and bottom at all, but ins$$anonymous$$d a little on the sides:
Answer by MrSoad · Dec 12, 2014 at 04:35 PM
The Dimension(Aspect Ratio) of your play field(BG Texture) seems to be constant. So download the image below, import it into Unity, in it's import settings set Alpha Is Transparency to true, place this on a Quad with a Transparent Shader. Now stretch the Quad until your play field(BG Texture) fits perfectly in the transparent window of the texture.
Now hopefully this will mask the borders regardless of the display aspect ratio.
thanks that did the trick, i just used it as a sprite. now im running into a totally different problem of objects being trigered as "visible" to the camera while they're still in the mask zone :) so they're invisible to the player but the camera still detects them and makes them interactable. Almost perfect though!
Not sure about how to fix your new problem but will let you know if I think of anything :)
That is odd, you have accepted the question but it is not showing as such on any page other than this... Not seen that happen before...???
server issues probably.
Anyway i found another thread with a efficient solution http://answers.unity3d.com/questions/437116/onbecamevisible-question.html
i just have to convert it to 2D form and should be good to go.
uh oh just realized that since a solution uses a raycast id need a collider attached to the black part which doesn't really work with the image with a transparent middle.
BUT i also realized that you were right before in ur previous suggestion about black border objects!
I just snapped 4 wide black boxes on all 4 sides of the main game view and added box collider to each, and it works just fine :) I got confused before.
Your answer
![](https://koobas.hobune.stream/wayback/20220613173900im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Dynamically instantiated game objects not showing in main camera (with background camera) 3 Answers
Camera Culling mask/ background color issue. 0 Answers
Why can't I see my objects in the scene view when adding a background image and a background camera? 1 Answer
I'm having trouble with Color.Lerp() 0 Answers
Two Levels of Directional Lighting For Different Cameras 1 Answer