Export scene when mesh filter has no mesh fails
In method: private MeshPrimitive[] ExportPrimitive(GameObject gameObject)
meshObj is null when the mesh filter has no mesh (it happens sometimes when unity messed up when reimporting file, loosing reference to the mesh).
It should at least not stop the process and report the problem.
Could you give us an example scene where this happens? @azakariaMSFT
Yes, i'll try to do one if needed but it is simple to reproduce: just add a cube in the scene, select the mesh field of the MeshFilter comlponent and press del. Then try to export. Looking quickly at the code, I guess the fix would be line 545:
if (transform.gameObject.GetComponent<MeshFilter>() != null
**&& transform.gameObject.GetComponent<MeshFilter>().mesh != null**
&& transform.gameObject.GetComponent<MeshRenderer>() != null)
{
prims.Add(transform.gameObject);
}
I put a fix for this in the staging branch along with additional fixes to export. Could you try it out and let me know
@azakariaMSFT did this fix make it in?
Sorry, I didn't tried in the staging branch but I saw the fix in the master branch now. Just tried and the mesh correctly ignored with an appropriate error message. I guess this issue can be closed.
Maybe I talked too fast. Maybe I'm wrong but I think the primitives attribute of meshes is mandatory, so the exported file in this case is not valid (if the MeshFilter doesn't contains sharedMesh, the exported file contains a mesh with just the name as attribute).
Please update to the latest version and open a new issue if the problem persists. Thanks!