UnityGLTF icon indicating copy to clipboard operation
UnityGLTF copied to clipboard

Export scene when mesh filter has no mesh fails

Open ultrasuperpingu opened this issue 8 years ago • 7 comments

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.

ultrasuperpingu avatar Nov 06 '18 11:11 ultrasuperpingu

Could you give us an example scene where this happens? @azakariaMSFT

ericob avatar Nov 12 '18 19:11 ericob

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);
}

ultrasuperpingu avatar Nov 12 '18 20:11 ultrasuperpingu

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 avatar Nov 16 '18 01:11 azakariaMSFT

@azakariaMSFT did this fix make it in?

ericob avatar Jan 04 '19 22:01 ericob

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.

ultrasuperpingu avatar Jan 08 '19 17:01 ultrasuperpingu

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).

ultrasuperpingu avatar Jan 08 '19 18:01 ultrasuperpingu

Please update to the latest version and open a new issue if the problem persists. Thanks!

robertdorn83 avatar Feb 09 '24 08:02 robertdorn83