Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in UnityGLTF.GLTFEditorExporter.ExportPrimitive #627

Closed
lvault opened this issue Jun 22, 2021 · 1 comment · Fixed by #644
Closed

NullReferenceException in UnityGLTF.GLTFEditorExporter.ExportPrimitive #627

lvault opened this issue Jun 22, 2021 · 1 comment · Fixed by #644

Comments

@lvault
Copy link

lvault commented Jun 22, 2021

I ran into this issue while exporting some GameObjects:

NullReferenceException: Object reference not set to an instance of an object
UnityGLTF.GLTFEditorExporter.ExportPrimitive (UnityEngine.GameObject gameObject) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:530)
UnityGLTF.GLTFEditorExporter.ExportMesh (System.String name, UnityEngine.GameObject[] primitives) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:500)
UnityGLTF.GLTFEditorExporter.ExportNode (UnityEngine.Transform nodeTransform, System.Int32 nodeCount) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:404)
UnityGLTF.GLTFEditorExporter.ExportNode (UnityEngine.Transform nodeTransform, System.Int32 nodeCount) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:419)
UnityGLTF.GLTFEditorExporter.ExportNode (UnityEngine.Transform nodeTransform, System.Int32 nodeCount) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:419)
UnityGLTF.GLTFEditorExporter.ExportNode (UnityEngine.Transform nodeTransform, System.Int32 nodeCount) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:419)
UnityGLTF.GLTFEditorExporter.ExportNode (UnityEngine.Transform nodeTransform, System.Int32 nodeCount) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:419)
UnityGLTF.GLTFEditorExporter.ExportNode (UnityEngine.Transform nodeTransform, System.Int32 nodeCount) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:419)
UnityGLTF.GLTFEditorExporter.ExportNode (UnityEngine.Transform nodeTransform, System.Int32 nodeCount) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:419)
UnityGLTF.GLTFEditorExporter.ExportScene (System.String name, UnityEngine.Transform[] rootObjTransforms) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:356)
UnityGLTF.GLTFEditorExporter.SaveGLTFandBin (System.String path, System.String fileName) (at Assets/PlattarExporter/UnityGLTF/Scripts/GLTFEditorExporter.cs:200)
Plattar.Exporter.GenerateGLTF (UnityEngine.GameObject selectedObject) (at Assets/PlattarExporter/Plattar/Editor/Exporter.cs:243)

After looking at the source file, it looks like GLTFEditorExporter.ExportPrimitive calls GLTFEditorExporter.getMaterials, which is a method that can return null. Though, the returned value isn't checked and thus using it throws the exception.

@hybridherbst
Copy link
Collaborator

Should be fixed on the dev branch
and in

Would be great if you test that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants