Search Unity

Timing problem when using AssetPostprocessor to control asset bundle assignments

Discussion in 'Scripting' started by cory_munky, Nov 16, 2015.

  1. cory_munky

    cory_munky

    Joined:
    Dec 10, 2014
    Posts:
    66
    Our project has a lot of assets. The spec for what assets go into what bundles is too complicated and dynamic to expect our artists to manage manually. Instead, we prefer to automate everything and let the artists get back to making art. Unfortunately, it only works most of the time.

    I'll make a change to the rules assigning assets to bundles in AssetPostprocessor, reimport everything to apply that change, check in the new code and all of the modified .meta files and everything looks great.

    But, then an artist will update from source control, Unity will see a bunch of modified .meta files, run the old AssetPostprocessor code which promptly changes all of the .meta files back to the old scheme. Only after that does Unity notice that the AssetPostprocessor code changed and should be recompiled. This leaves the artist confused about how updating from source control puts a bunch of files they didn't touch into a state that's inconsistent with source control! :confused:

    Any suggestions on how to improve this situation?
     
  2. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    Yeah, I've had similar issues.

    What I tend to do is have a source art asset and get our auto importer pipeline to create new prefabs and assets that are ready for game use. That way the source assets that artists touch are never updated and changed by the import scripts.

    The generated assets can then be left out of source control and can be generated locally for all people on the project. This will remove the problem of conflicting assets an automated system.

    The biggest issue with this however is you have to be vary wary of references directly to these assets. As they are generated they will not exist for new users or a clean checkout of your project so you'll have to reference them in other ways in your scenes and other prefabs etc, via file names or some custom asset manager for example.

    I'll let you know that I've only ever used a system like this to manage items in a character costume system, it works very well for that sort of thing because you'll want to load costume items dynamically and not want references in your scenes and other prefabs... I didn't attempt this for objects expected to be used for levels for the referencing issues stated above. It'll be solvable but I didn't think it was worth it in our case.