[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.

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.

@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.

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.

Instead of adding Sprite directly follow these steps:

  1. Create an empty game object
  2. Add Image component
  3. Assign your Sprite to Image component.

Now it will appear

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.

Try Changing Sorting Layer by adding a layer, SortingLayer should never be default,
To add a layer go to your Inspector click on Default then click Add Sorting Layer then you will find Tags ,Sorting Layers ect… ,Click Sorting Layers and click the + button name your layer and your done

in your Sprite’s Inspector Click on default close to Sorting Layer click add sorting layer, then you will see things Tags,Sorting Layers and Layers, Click on the sorting layers and click +, name your layer and test your game

Hope it Works

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.

I solved it.
Change canvas Render mode to Word Space and resize it, then in Canvas Scaler put Dynamic Pixels Per = 100 and in Reference Pixels Per = 1

mine was i had negative values in the z axis XD

I forgot to create a raw image GO, and then make my jpg image its texture. Now it shows in my camera view and when built.

Try set main Camera → Culling Mask to Everything. Works for me.

I got same problem too and I found the source of the problem.

Set CameraClipping PlanesNear to 0.

It comes default 0.3 and this means Camera does not render anything closer than0.3 distance.

I had a similar problem. I just went into 3D, then I found that my sprite was behind the camera.