Unity 4: Problem with PrefabUtility.CreatePrefab

A line of code that worked perfectly in Unity 3.5.6, does not work in 4.

GameObject gObj = PrefabUtility.CreatePrefab(name, go);

Basically, the prefab is not copying correctly. Anything that relates to the mesh, does not copy over. A reference in the SkinnedMeshRenderer, as well as my own script, become null. On top of that, the animation clips all become null.

This is happening in the OnPostprocessModel.

Is this a known issue and is there a work around?

EDIT: After further investigation, this only happens when a prefab is created in OnPostprocessModel. I was able to reproduce it effectively in a clean project and created a bug report https://fogbugz.unity3d.com/default.asp?498132_a8unhv4c81qjeuni

I have the same problem in 4.2! :frowning:

Have you find solution, or workaround?

I have find workaround!

PrefabCreator.Create    ( assetPath, "Assets/Prefabs/Platforms/" + platform.name + ".prefab" );
private class PrefabCreator{
    private PrefabCreator    ( String source, String destination )                        
    {
        _source                            = source;
        _destination                    = destination;
        EditorApplication.update        += CreatePrefab;
    }


    private        String        _source;
    private        String        _destination;


    public static    void    Create            ( String source, String destination )        
    {
        new PrefabCreator ( source, destination );
    }
    private            void    CreatePrefab    ( )                                            
    {
        var model                        = (GameObject)AssetDatabase.LoadAssetAtPath ( _source, typeof(GameObject) );


        if( model == null )
        {
            Debug.Log        ( "[PrefabCreator] - CreatePrefab: Wait For Model at " + _source );
            return;
        }


        var prefab                        = PrefabUtility.CreatePrefab ( _destination, model, ReplacePrefabOptions.ReplaceNameBased );
        EditorUtility.SetDirty            ( prefab );
        AssetDatabase.LoadAssetAtPath    ( AssetDatabase.GetAssetPath ( prefab.GetInstanceID ( ) ), typeof(GameObject) );


        Debug.Log                        ( "[PrefabCreator] - CreatePrefab: PrefabCreated " + _destination, prefab );


        EditorApplication.update        -= CreatePrefab;
    }
}