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.