black borders top and bottom of screen in 1920,1080

I understand the black borders are to do with aspect ration but I don’t know how to fix it. This means if I have a sprite which moves off screen, down for example, it is shown over the black part of the border instead of being cut off by the parameters of the screen height, and the image remains there even after removing/destroying the sprite.

I’m setting my screen res to 1920,1080. But I don’t want to stretch the sprites as all of them are made for that res.

Three (3) primary ways that Unity draws / stacks / sorts / layers / overlays stuff:

https://discussions.unity.com/t/841904/2

In short, as far as the Standard Rendering Pipeline,

  1. The default 3D Renderers draw stuff according to Z depth - distance from camera.

  2. SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties

  3. UI Canvas Renderers draw in linear transform sequence, like a stack of papers

If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:

  • identify what you are using
  • search online for the combination of things you are doing and how to to achieve what you want.

There may be more than one solution to try.

For instance, you may even use multiple co-located cameras to more-explicitly control apparent draw ordering.

Additional reading in the official docs:

https://docs.unity3d.com/Manual/2DSorting.html

And SortingGroups can also be extremely helpful in certain circumstances:

https://docs.unity3d.com/Manual/class-SortingGroup.html

Other rendering pipelines may have other ways of layering (HDRP and URP). Go see the latest docs for details.

There’s lots of third party open source packages available as well, such as this:

https://github.com/mob-sakai/ParticleEffectForUGUI

1 Like

Difficult to explain this, but I’ll try. I set up two cameras and two canvases to test this. On the first one I attached an image and set the canvas to 1920,1080. In free aspect I can see the black border top and bottom, which is fine. Just so I know it’s there. Now I do exactly the same thing, make another camera, add a canvas, add an image same size but now when I switch between them the second one never shows the borders top and bottom in free aspect. Both have exactly the same settings, yet second one never seems to fix the res size properly.

I can switch between both and see the first will size with borders in free aspect, the second one which is exactly the same will not, it will fill the whole screen

It’s not just the Canvas. It’s the RectTransform, where it is in the world, the CanvasScaler, etc.

Any reason you’re fiddling with all this crazy complexity? Why not just set the Game window to 1920,1080 and finish your game?

Once your game is 100% complete, it’s trivial to go back and throw black bars over the top and bottom when it gets run on a taller screen, or on the left and right when run on a wider screen, using whatever canvas-on-top-of-everything scheme you like.

1 Like

The bars are there as letterbox already. I’m trying to prevent rendering of the image in the letter box area. I set game to 1920,1080 and it has letterbox(ing) but when images are drawn if they are outside the 1920,1080 area instead of being clipped at the bottom or top they are rendered over the black borders/letterboxing. Hopefully you see what I mean

In that case refer to my original post above, taking as “inputs” to your brain the letterbox and the thing that is inappropriately overlaying it.

1 Like

Well I think the solution lies in Mask, RectMask. Currently tinkering with it. Thanks.

Yep RectMask is what I needed. Thanks for trying to help as always.

1 Like

Well it wasn’t the solution in the end, but I found that out myself yesterday. Was something to do with the camera settings which I discovered when trying to change the rect settings etc, but as I said, as a beginner, I appreciate the help I get on here which often points me in the right direction even when I feel I don’t have a clue what I’m doing. Wasn’t so much what you said as how you said it. But anyway.