Search Unity

Batching my own meshes with SpriteRenderer

Discussion in '2D' started by Jeiel, Jan 9, 2014.

  1. Jeiel

    Jeiel

    Joined:
    Apr 23, 2013
    Posts:
    7
    Is it possible to dynamically batch my own meshes along with other SpriteRenderers? I'm generating my own meshes that use the generated atlas from SpriteRenderers but I'm not getting any savings on the draw calls. I'm guessing my own meshes aren't being sent along with the meshes from the SpriteRender.

    $mesh-batching.png

    As an example, the objects on the left are my own, the ones on the right are using SpriteRenderer's. My own objects are using the atlas texture from the SpriteRenderers and I've assigned the same material to all of the objects in my test scene but from the draw call count, the meshes in my scene aren't being batched together.
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I think the Sprite Renderer batches based on different rules. For example it's possible for sprites to have different scaling without breaking batching, whereas with game objects a change of scale can break a batch. So I'm guessing maybe Unity only runs through all the sprite renderers to consider how to batch them separately, and then looks at gameobjects as a separate set to be batchable.. .but still distinct from any batching that happened already?