Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Sorting layer for MeshRenderer not working

Discussion in 'General Graphics' started by wreckostudios, Mar 1, 2016.

  1. wreckostudios

    wreckostudios

    Joined:
    Oct 8, 2015
    Posts:
    7
    I currently cannot get a Quad to render behind the sprites in my scene. I want to use a Quad because it is easier to tile textures on them for background.

    I have added the following script to a GameObject that has a MeshRenderer on it. The GameObject is just a default Quad.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class RenderLayerSetter : MonoBehaviour {
    6.    void Update() {
    7.        GetComponent<MeshRenderer>().sortingLayerName="Background";
    8.    }
    9. }
    10.  
    This sorting layer does indeed exist, and regardless of what sorting layers I assign anything, the Quad will always be in front of the sprites unless I change its 'z' value (which is an unacceptable work around).
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Why?
     
  3. Rhiojin

    Rhiojin

    Joined:
    Dec 12, 2012
    Posts:
    8
    This issue for me was fixed using a shader with transparency. for example: unlit/transparent
     
  4. xCyborg

    xCyborg

    Joined:
    Oct 4, 2010
    Posts:
    624
    Yep, it's a bummer, mesh renderers don't work well with particle systems and sprites.