Search Unity

Tile sprites don't appear in the game view

Discussion in '2D' started by manolopzy, Oct 27, 2020.

  1. manolopzy

    manolopzy

    Joined:
    Oct 15, 2020
    Posts:
    6
    I am new in using Unity. I'm really getting confused by the "sorting layers". I have created four sorting layers, and assigned the "Background" layer to the main camera's Background, "Foreground" layer to all tile prefabs and the "Player" sprite, but I can see the tiles only in the scene view not in the game view. Thank you if someone can help me this out!
    sorting layers
    upload_2020-10-27_11-16-53.png
    scene view
    upload_2020-10-27_11-17-55.png
    game view
    upload_2020-10-27_11-21-29.png
     
  2. Derekloffin

    Derekloffin

    Joined:
    Mar 14, 2018
    Posts:
    322
    I suspect they are behind the camera in the Z axis. Check your camera position and tile positions and see if it is out of whack with the that which does show up.
     
  3. manolopzy

    manolopzy

    Joined:
    Oct 15, 2020
    Posts:
    6
    You are right, I have changed the z depth of the Main camera to -1, and the "Background" of the camera to 1, cannot be 0, I think it is because there is another layer which is the Skybox whose depth is 0. But this still confuse me, because it should be their sorting layers determine which layer will be rendered on top of each other right? All my tile prefabs has a higher sorting layer than the camera background, it was covered by the camera background.
    Ok, now it is fixed, I don't know why, the problem has gone, I just exchanged their sorting layer then changed them back, and it's gone. Thank you very much!!
     
  4. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @manolopzy

    I think @Derekloffin might have meant this. One reason you might not see objects is if they are behind the camera near clip plane... although I have no idea if that is the case here.

    blocks.gif
     
  5. Derekloffin

    Derekloffin

    Joined:
    Mar 14, 2018
    Posts:
    322
    I'm still a bit unsure how 2D sorting works myself, but my impression has been that Z > Sorting layer > sorting order as far as how sorting works. Usually everything in your 2D game with have the same Z (save the camera) so that usually shouldn't matter, but the Z coordinate still does exist and does do things. Best thing is to just avoid the issue by having all your 2D assets have the same Z position, usually 0.
     
  6. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The SceneView camera and the Camera used in the GameView are different, so you could see different results. Selecting the GameObject of the Camera will add an overlay which you can check if there is a Camera settings issue.

    The 2D sorting guide is here (https://docs.unity3d.com/Manual/2DSorting.html), do let us know if anything is unclear!