Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

RenderQueue and Prefabs

Discussion in 'Shaders' started by imaewyn, May 18, 2017.

  1. imaewyn

    imaewyn

    Joined:
    Apr 23, 2016
    Posts:
    211
    Hello. I have prefab with transparent material which I instanciating at runtime many times. If instanced objectes overlay each other then I have bug like z-fighting. Changing renderQueue fixs this situation but it seems break batching. If any way to change renderQueue with save connection to prefab for object?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Render queue will absolutely break batching, there's no way around that. Use sorting order instead:
    https://docs.unity3d.com/ScriptReference/Renderer-sortingOrder.html

    This should work on all renderers, though it's only exposed (and saved) on SpriteRenderer components in the editor, but that shouldn't be a problem for you since it sounds like you're going to be setting this via script at runtime anyway.
     
  3. imaewyn

    imaewyn

    Joined:
    Apr 23, 2016
    Posts:
    211
    Thanks!)