Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

[Free] Model optimizing post processor

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

  1. Deleted User

    Deleted User

    Guest

    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: https://gist.github.com/nickgravelyn/9654795. 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: http://brushfiregames.com/shipwreck.
     
  2. TrialByFun

    TrialByFun

    Joined:
    Jun 23, 2009
    Posts:
    97
    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

    V0odo0

    Joined:
    Jan 8, 2012
    Posts:
    328
    Useful. Thanks for sharing!