- Home /
[SOLVED] Sprite showing up in "Scene", but not in "Game"
Before I begin: I've already tried everything already on the forums with relation to the Z axis, and that hasn't worked, so please avoid answering with that as a solution.
With that in mind, my problem is more or less the same - a sprite shows up in the "Scene" view, but not in the game, and, for the life of me, I can't figure out what's wrong. Screenshot link below.
Note: everything is on the canvas, and the canvas is set to Screen Space - Overlay, so it shows up on camera.
Due to the two screenshot limit, I've linked to them here.
Did you try and change it's order in layer? Otherwise I am thinking it could be a camera setting, are you using perp or ortho?
@Captain$$anonymous$$irby: The camera is in orthographic mode.
Answer by hiflyer380 · Sep 08, 2015 at 04:39 AM
Got it! I set the canvas to Screen Space - Camera, and set the Render Camera to Main Camera. Also, I created a small 1 pixel by 1 pixel black square to use as my camera icon so it doesn't block my view.
Except now all of my UI elements are missing in the Scene View but visible in the Game View (exact opposite problem). Oh Unity.
Hey there, do you think you could elaborate on what you mean by "set the Render Camera to $$anonymous$$ain Camera?" I'm having an issue where literally every sprite is invisible in my Game Tab.
Oh my god. For some reason, when my character loaded in, his Z position was 90. The level's Z position was 0, so the camera was physically behind the level. Whoops.
Answer by davisj16usmc · Sep 08, 2015 at 02:03 AM
@hiflyer380 Take a screen and post it; your problem may be with the X and Y positions. GUI objects use a position base between 0 and 1. It's the biggest problem with 2D objects in Unity in my opinion. You should use Screen.Width and Screen.Height to place your sprites, text, and other 2D objects in the scene so they remain visible in all resolutions. Also ensure you're not designing in Free Aspect; use a ratio like 16:9 or 4:3 to design so you know they'll at least be visible in the game.
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.
Yep, this was my issue. I switched to 3D mode, and my Z value was like -100 something. I was wondering why I was able to collide with the objects in 2D mode, but couldn't see them
Answer by HernandoNJ · Mar 18, 2020 at 07:42 PM
I shouldn't change Canvas camera settings because of my code. I tried changing layers, didn't work. I figured out that axis Z was -456.7297 so, I changed it to 0 and it worked ok.
Answer by davisj16usmc · Sep 08, 2015 at 02:05 AM
Just tested because I'm used to Unity 4; here's the result:
As you can see it worked; Sprites use a different position system than canvas objects. Don't attach your sprite to the canvas; set it's position to -8 on the z axis, and switch your canvas to world space and move it back until everything looks the way it should again. You can usually just move it back and alter the scale. That usually does the trick. Always remember how the camera views things; even in 2D games it uses the z axis to set depth of objects. Things closer to the camera will appear on top of things further away. In my case the a and b images are ui images and the x is a sprite. All three are set as sprites in the texture settings.