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?
yes, I do have sublime configured as script editor in Unity, but it seems that it causes some troubles with rebuilding sln and csproj files. Maybe I should switch back to vs and open sublime manually.
I see a dozen of these questions asked and unanswered; this is the only one answered incorrectly in my opinion. We're assuming you set Overlay for a reason so I would add an image asset to the Canvas in the scene and then select the sprite in the properties of the image.
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.
Hey there, do you think you could elaborate on what you mean by "set the Render Camera to Main Camera?" I'm having an issue where literally every sprite is invisible in my Game Tab.
In my case, i was using only the FPS Camera, so the solution was set the Canvas to WorldSpace, and then dragging the FirstPersonCharacter (Camera) to Event Camera.
@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.
KwahuNashoba's comment worked for me! I simply opened up my Unity 2018 project with Unity 2017. The .sln project files were generated when opening any script in Unity 2017. Then simply reopen the project with Unity 2018, and it works.
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.
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.
Just had this issue. Was this exactly. Thanks a ton!
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
You are my savior. I had a similar issue and figured out that my custom shader material renders only from one side. I had to change the ‘Render Face’ option in the shader graph settings to ‘Both’ to always see the sprite from both sides in the Scene and Game view.
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
@abraham5361: Adding a new layer and sorting the sprite to it does not change anything.
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.
@localnoob Back then I think I was using Unity 5. I'm now on Unity 2019 and I've come back to find out why my sln is not being generated. I guess they broke it somewhere along the way.
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?
– CaptainKirby@CaptainKirby: The camera is in orthographic mode.
– hiflyer380yes, I do have sublime configured as script editor in Unity, but it seems that it causes some troubles with rebuilding sln and csproj files. Maybe I should switch back to vs and open sublime manually.
– kakyshaI see a dozen of these questions asked and unanswered; this is the only one answered incorrectly in my opinion. We're assuming you set Overlay for a reason so I would add an image asset to the Canvas in the scene and then select the sprite in the properties of the image.
– korlinga