Set sortingLayerName and sortingLayerId properties in renderMode renderMode. ScreenSpaceOverlay situation will not take effect, Leave sortingLayerName=Default and sortingLayerId=0. When the renderMode property is read, the following judgments are performed:
RenderMode {get {...if(m_renderMode == RenderMode.ScreenSpaceCamera && m_camera == null)
{
returnRenderMode.ScreenSpaceOverlay } ... }}Copy the code
Therefore, to change sortingLayerName and sortingLayerId, you must set the Camera first