- Home /
screen background not clearing in standalone/web player build
I have a camera object whose position changes based on player input. In the Unity editor, this works great - there is a small screen that moves around on a black background and generally looks awesome.
The only problem is when I export to web player or standalone, for some reason the background doesn't clear after my camera's position changes. Instead I get a smear of camera scene that follows my screen.
Any ideas as to how to fix this? Ideally I'd like to just set some flag that causes the background to clear to black and then have my new camera scene rendered on top of it, every frame. Would adding another camera layered underneath it work, and if so, what's the best way to get it to render black?
Answer by Berenger · Mar 10, 2012 at 06:05 PM
Try with a second camera with a clear flag "solid color", the color being black. I guess for some reason you need the first camera to have the clear flag at depth only ?
The first camera has clear flag solid color, and I tried making that solid color black, but to no avail
I implemented the solution presented here: http://answers.unity3d.com/questions/9729/how-can-i-display-a-flat-background-2d-image-not-a.html
It worked great!
Could you explain what you mean by "a small screen that moves around" ? Do you mean the camera render on only part of the screen, like a viewport (0.2,0.2,0.5,0.5) and that the user inputs are changing that rect ?
Anyway, I ran into a similar problem about the color buffer, when the gameView isn't on free aspect, it's not behaving like the build, for some reason.
That's exactly what I mean (there are actually multiple cameras whose Rects, both in size and position, change). The root cause of the problem might have something to do with colorBuffer and aspect, but making a background image seemed to solve my issues without me having to fully understand them :)
The background image forces the all screen to be redrawn, so the last frame is flushed.
Your answer
Follow this Question
Related Questions
Change the background color attribute of a camera in C#? 2 Answers
(C#)Changing Camera Background Via Code 1 Answer
How to move the background in unity2d for ios game 0 Answers
how to hide background from this shader ? 0 Answers
How can I create a gradient color background for my game, without using skybox? 2 Answers