AssetPostProcessor prefab creation error

I’m trying to wrap an imported model in a prefab, but while I get the right contents, certain components are missing. I’m feeding the imported GameObject (in OnPostprocessModel()) to PrefabUtility.CreatePrefab(), and the resulting prefab has the mesh, but the meshfilter’s mesh is empty. What’s that about?

Here’s a simplified version of the code:

public void OnPostprocessModel(GameObject gameObject)
{
    var isZombieElement = assetPath.ToLower().Contains("models/zombies/");
    if (isZombieElement)
    {
        var prefab = GetOrCreatePrefab(gameObject);
    }
}

I’ve attached an example project that includes a good old teapot.fbx and barebones custom processor. You can see that the generated Prefab is kinda empty (no mesh in meshfilter)

1117354–42147–$AssetProcessorIssue.zip (234 KB)

bump on this.

just ran into same issue.

d’you ever make any progress duke?

hi

Exactly this problem and the reason for the change in described in the upgrade guide in the section: Changes to the asset processing pipeline
http://docs.unity3d.com/Documentation/Manual/UpgradeGuide3540.html

The correct place to copy assets is in OnPostProcessAllAssets, only at this point in the asset pipeline has all the information been correctly written to disk.

got it.

bummer of a change for my pipeline, but good to know.

thanks for the info SteenLund.

How are you supposed to get a reference to the imported object with this “upgrade?” With OnPostprocessModel, it was inherent. OnPostprocessAllAssets only gives you the name of the model you’re importing.

Edit: Figured it out for anyone who’s curious. Use AssetDatabase.LoadAssetFromPath to get a reference to the GameObject. It would be helpful to put in that Unity 4 Changes Documentation.