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

If a mesh only occurs in the scene statically and is batched, is the source mesh still in build?

Discussion in 'General Graphics' started by o1o101, Aug 24, 2021.

  1. o1o101

    o1o101

    Joined:
    Jan 19, 2014
    Posts:
    639
    In otherwords, are meshes which are only statically batched excluded from the build?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    The mesh is "included" in the build as part of the static batch mesh, possibly several times, as each placement of a static mesh becomes unique vertex data pre transformed into world space and combined into a single large mesh used by the static batching system..

    The original source mesh is not included in the build though, if it is not used by anything not static.

    Basically, if you're worried about memory usage, it's not a problem. But also static batching uses a ton of memory compared to a single mesh so it wouldn't really be a concern even if it was.

    If you're trying to manually render a single game object's mesh by itself, you can't access it's shared mesh at runtime because it's the single huge static mesh now and not the original source mesh. Though you can use command buffers and DrawRenderer() to render a single object by itself with another material if need be.