Can I modify a mesh via editor scripts

Hi there,

I try to combine the sub mesh of a fbx model to root when importing it. I've combined sub mesh successfuly at runtime before. But when I do the same via editor script ( in OnPostprocessModel() in a subclass inherits from AssetPostprocessor), the result mesh is null. The part of code like this:

    SkinnedMeshRenderer render = go.GetComponent<SkinnedMeshRenderer>() as SkinnedMeshRenderer;
    if (render == null)
        render = go.AddComponent<SkinnedMeshRenderer>() as SkinnedMeshRenderer;

    render.sharedMesh = new Mesh();
    Debug.Log("combine count is " + combines.Count.ToString());
    render.sharedMesh.CombineMeshes((CombineInstance[])combines.ToArray(typeof(CombineInstance)), false, false);
    Debug.Log("render.sharedMesh.subMeshCount is" + render.sharedMesh.subMeshCount.ToString());
    Debug.Log("render.sharedMesh.vertexCount is" + render.sharedMesh.vertexCount.ToString());
    render.sharedMaterials = (Material[])materials.ToArray(typeof(Material));
    render.bones = (Transform[])bones.ToArray(typeof(Transform));

The log shows that the subMeshCount and vertexCount of result sharedMesh are not zero. But when I dorp the asset to sence it shows nothing, and the inspector shows it's mesh is missing while all materials exist. I guess it's due to I can't save the result to the import asset because it's a fbx file, or is there something I've missing ? I'll be very greatful on your help.

You created an instance of Mesh in memory, but the Mesh is not saved as asset. I've never done this with a mesh, but i guess you have to use AssetDatabase.AddObjectToAsset. The example there adds an AnimationClip to a material. The clip shows up as child of the material ( kinda crazy ;) ).