Sprite background
Sprite is visible in the scene, but not in a build or in game view. Tried sorting layers etc. changing position, rotation, scale. Nothing worked so far. Alpha isn't affected at all during play mode.
Any ideas?
Here's a screenshot of the inspector. No script is referencing to this sprite. No settings have been changed in the main camera and there is no other camera.
Answer by Crixu · Oct 26, 2015 at 06:04 PM
The problem was the Z position. By resetting the position of the sprite (or just the Z position) it worked out for me.
The thing I probably did wrong was setting the sprite as a child of the camera and then resetting the position etc. This changed the Z position to the exact same as the camera, clipping it through the "lens" (near clipping plane).
Answer by Statement · Oct 25, 2015 at 05:37 PM
Does it (or any parent) have the tag EditorOnly? It will strip it out of the build.
Or, perhaps some piece of code is turning it off, setting alpha to zero or otherwise moving the sprite when you hit play.
If it's far out, perhaps it's outside the cameras clipping planes.
As far as I know I haven't used EditorOnly at all, and in the code I've applied to the background I don't change that alpha or anything at all. Pausing play mode and looking at scene view still shows the background with the camera focused on it. Camera has Z -10 and the background at Z 0.
Also, it's a 2D game so it's an orthographic camera.
I know, but it might be worth mentioning ;)
Is there something I could've overlooked perhaps?
Your background is at z -10 which is the default position for a camera in Unity. It would be clipped if you kept it there and if you haven't moved your camera. Try setting z to 0 and see if it pops into view.
Otherwise I don't know if it's a far fetch, but try turning off occlusion culling if you had it on. I dont know if it affect sprites.