- Home /
Sprites Become Invisible (SOLVED)
I'm a beginner, and I'm making a 2D pong game in Unity 4.3. Yesterday, all of my sprites were displaying properly, but today I open up the project to find that some of my sprites had turned invisible.
They still exist, and I can see the wireframe when I click them, but they are not visible in scene view or in the game, even when it runs. As you can see from the pictures, one of the paddles, and one of the score barriers are invisible.
If I duplicate one of the invisible sprites, the duplicate is visible, but then another sprite turns invisible. All of those sprites, save the background and the camera, are on the same layer. I have restarted Unity and restarted my PC to no avail.
Can anyone tell me what's going on here? Is this a bug, or did I possibly set something up wrong?
Thanks in advance :)
What happens if you drag the Player prefab from your Sprites folder into the scene viewport, does it display fine? You don't appear to actually be using the prefabs, since the objects in your scene have black text and no (Select/Apply/Revert) at the top of their attribute window. The Hierarchy text should be Blue when you're using the prefab version.
Invertex, there are no prefabs. I don't even know what those do yet :S
Ah right, I see you only have sprites. Alright, well, I would say to just delete the object and drag the sprite back into your scene, and attach the script you have for it again. Does that work? I would look into what prefabs are and how you use them. To put it simply, you drag an object from the scene Hierarchy into your project folder, and you create a prefab of that object which exists outside the scene, and can be modified to affect the one in the scene.
Yup, that fixed it! Thank you so much, Invertex, you just saved my day :)
So what was happening there? Should I always ensure none of my Sprites are on the Default sorting layer? Why is that bad?
Awesome, that makes perfect sense. At first I found it odd that bottom layers are rendered on top of top layers (as opposed to Photoshop), but when I thought about it a bit more, I realised it's not following visual logic, but code logic. Code executes from top to bottom, so it makes sense that the later things are rendered, the more on-top they are.
Thanks again :)
Answer by Invertex · Jan 06, 2014 at 06:58 AM
I see that your SortingLayer in your SpriteRenderer is set to default, try changing it, that's the layer system that determines render order for sprites. As it seems like this is a render order issue.
That helped me out too. For some reason, when I was working on my project last night, everything was showing up fine. Open Unity this morning, Sprite is hidden. No change in code, nothing. Well, sure enough, I changed the order and that fixed that.
How do you modify the order, though? I can see the "order in layer" field. I suppose higher numbers give priority? Like if I have a background, a middle and a foreground layer, do I give background elements a 0 value, the middle gets a 1 and foregrounds a 2? Or is it the other way around?
@1singur Yes that is how you modify the render order of the sprites. I don't recall whether it's a higher or lower number that's rendered first, as it's been a while since I used the system, so just test it out and see! :)
You can also create sorting layers to group together types of sprites, like all background related sprites in one render layer, and mid-ground in another. So everything in the background layer will always render behind the mid-ground sprites, regardless of "Order in Layer", as that order only affects sprites within a given layer.
Thanks, that helped me out too! Such a simple issue, hahah- glad there's also a simple solution.
Answer by WhiteCastle · Sep 26, 2017 at 05:08 PM
In case anyone else come across this, I had a similar issue. I was in 2D mode and my sprite was rotated such that it was perpendicular to the camera, thus invisible. It is really obvious if you swap to 3D mode.
Answer by monark · Apr 10, 2021 at 03:23 PM
If you are using URP don't get caught out by the same thing I did. In my Forward renderer data I had removed the UI layer from the transparent layer mask. This doesn't affect the rendering of the UI in game, but in the editor scene view it means no sprites are rendered, including the UI for no obvious reason....
Ah, the new layer I made was missing from my Forward Renderer Data!
Answer by thehuhuboy31 · Oct 19, 2020 at 09:25 PM
Alright, The same problem occurred to me when i relaunched my project. everything was invisible but the background was just present. After thinking about it i moved the background just to see and my project was present there. So the solution i found was to remove like delete the existing background and take up the same but from the assets again in order for your project to be back on top.