Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

[Free] Model optimizing post processor

Discussion in 'Assets and Asset Store' started by nickgravelyn, Mar 20, 2014.

  1. nickgravelyn


    Jan 22, 2009
    For our new game, we're building the levels in Maya LT which is really nice for our workflow. We've been heavily using the AssetPostprocessor in Unity to let us tag objects with all sorts of data like physics materials and collision types (convex or concave). The one flaw we had is that this leads to a lot of duplicated objects.

    For example, make a scene in Maya LT. Create a single cube. Now duplicate that cube 10 times. Import into Unity. This is what you get:

    $Screenshot 2014-03-19 17.44.29.png

    That's a unique Mesh object for each cube. Hugely wasteful. Now, you could do this the "normal" way: export a single cube as an FBX and place it 10 times in Unity. But that breaks the workflow we're enjoying by having all level data be in our single Maya scene.

    So what I did was write an AssetPostprocessor to patch all this up. Anytime you import a model, it finds all the meshes inside and compares them. If it finds duplicates, it deletes the duplicate and updates references to it to point at the new mesh. With that in place that exact same scene now looks like this:

    $Screenshot 2014-03-19 17.45.16.png

    Big difference. The asset will now be much smaller on disk, much smaller in RAM, load faster, and likely render faster due to this cleanup.

    And since I found it so useful but I don't think it makes any sense to sell, I decided to put it up on Github's Gist service and let anyone have it. You can get all the code here: It's worked well in my few test scenes so hopefully it proves useful to others as well.

    If you find this code useful and feel so inclined, you can pay me back by picking up a copy of my company's first game Shipwreck:
  2. TrialByFun


    Jun 23, 2009
    Thanks for the script!

    I don't have something for it right now, but i can imagine i'd use it in the future!
  3. V0odo0


    Jan 8, 2012
    Useful. Thanks for sharing!