Home Unity

Instanced Mesh AssetPostprocessor (v0.1)

Guessmyname
polycounter lvl 6
Offline / Send Message
Guessmyname polycounter lvl 6
Hello there; I've been working with Blender and Unity for a while and discovered the awkward snag regarding instances; the importer makes every imported object a unique instance. Since I'm also using Blender as a level editor, you can see where this might be a bit of a problem...

I've written a quick AssetPostprocessor to try and catch duplicate mesh instances and clean them up; full technical deets (and code if you just want to copy/paste it) are here on my blog /obligatory shameless self-pimping.

To be completely clear, the post-processor does not detect instanced meshes! It compares meshes with the same names off against each other (where names are absent anything after the last underscore, such that the name 'Cube' and 'Cube_001' are 'the same'), checking submesh count, vertex count and the origins / sizes of their bounding AABBs to 'judge' meshes as being duplicates of one another.

Under specific circumstances, finding two meshes identical that aren't instances is perfectly possible, and equally it can find two meshes that are instances unique if they have different modifiers on them (which is probably desired behaviour to be honest).


It's one of those little Unity things that can be a complete pain in the ass to deal with; hope this helps some people!

If anyone has any problems with it / has advice on the mesh equality test (it should be thorough enough without directly comparing vertex lists), feel free to leave a message and I'll try and sort it out.

Replies

  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    Thank you, I will look into this as I'm using 3dsmax to build my levels and was searching for something like this. I hope it will serve me as good starting point to incorporate to my existing pipeline. I already using some asset postprocessors of mine which deal of making prefabs out of imported meshes, assign materials and save it to respective folder automatically. Your tool could be very handy for levels and maybe other stuff as well.
    Definitevely looking into this. :) Thank you again for sharing.
  • mookster
    Options
    Offline / Send Message
    mookster polycounter lvl 18
    @cupsster just so you know, check preserve instances on the fbx export options in max will do exactly that. Instances will correctly point to one mesh in the project browser.

    @Guessmyname not trying to take away from the awesome work youve done. Im sure for blender fbx export this is greatly needed.
Sign In or Register to comment.