NullReferenceException on USD export
See original GitHub issueI was attempting to export the blacksmith environment (Bridge_small_02 scene):
https://assetstore.unity.com/packages/essentials/asset-packs/the-blacksmith-environments-39948
…and got a NullReferenceException:
NullReferenceException: Object reference not set to an instance of an object
Unity.Formats.USD.MeshExporter.ExportMesh (Unity.Formats.USD.ObjectContext objContext, Unity.Formats.USD.ExportContext exportContext, UnityEngine.Mesh mesh, UnityEngine.Material sharedMaterial, UnityEngine.Material[] sharedMaterials, System.Boolean exportMeshPose) (at D:/Storage/3D/Unity/usd-unity-sdk-1.0.0-preview.4/package/com.unity.formats.usd/Runtime/Scripts/IO/Geometry/MeshExporter.cs:162)
Unity.Formats.USD.MeshExporter.ExportMesh (Unity.Formats.USD.ObjectContext objContext, Unity.Formats.USD.ExportContext exportContext) (at D:/Storage/3D/Unity/usd-unity-sdk-1.0.0-preview.4/package/com.unity.formats.usd/Runtime/Scripts/IO/Geometry/MeshExporter.cs:147)
Unity.Formats.USD.SceneExporter.ExportImpl (UnityEngine.GameObject root, Unity.Formats.USD.ExportContext context) (at D:/Storage/3D/Unity/usd-unity-sdk-1.0.0-preview.4/package/com.unity.formats.usd/Runtime/Scripts/IO/Scene/SceneExporter.cs:220)
Unity.Formats.USD.SceneExporter.Export (UnityEngine.GameObject root, Unity.Formats.USD.ExportContext context, System.Boolean zeroRootTransform) (at D:/Storage/3D/Unity/usd-unity-sdk-1.0.0-preview.4/package/com.unity.formats.usd/Runtime/Scripts/IO/Scene/SceneExporter.cs:158)
Unity.Formats.USD.SceneExporter.Export (UnityEngine.GameObject root, USD.NET.Scene scene, Unity.Formats.USD.BasisTransformation basisTransform, System.Boolean exportUnvarying, System.Boolean zeroRootTransform, System.Boolean exportMaterials, System.Boolean exportMonoBehaviours) (at D:/Storage/3D/Unity/usd-unity-sdk-1.0.0-preview.4/package/com.unity.formats.usd/Runtime/Scripts/IO/Scene/SceneExporter.cs:128)
Unity.Formats.USD.UsdMenu.ExportSelected (Unity.Formats.USD.BasisTransformation basisTransform, System.String fileExtension, System.Boolean exportMonoBehaviours) (at D:/Storage/3D/Unity/usd-unity-sdk-1.0.0-preview.4/package/com.unity.formats.usd/Editor/Scripts/Behaviors/UsdMenu.cs:180)
UnityEngine.Debug:LogException(Exception)
Unity.Formats.USD.UsdMenu:ExportSelected(BasisTransformation, String, Boolean) (at D:/Storage/3D/Unity/usd-unity-sdk-1.0.0-preview.4/package/com.unity.formats.usd/Editor/Scripts/Behaviors/UsdMenu.cs:184)
Unity.Formats.USD.UsdMenu:MenuExportSelectedWithChildren() (at D:/Storage/3D/Unity/usd-unity-sdk-1.0.0-preview.4/package/com.unity.formats.usd/Editor/Scripts/Behaviors/UsdMenu.cs:67)
I got the error when attempting to export the top-level “Environment” object in the hierarchy. I’m sure it’s erroring because there’s some entities that it can’t export properly (I don’t expect it to work on everything!), but it would be nice if it could perhaps print an error, and then continue on with exporting what it can. While it does indeed create a USD export, it seems to only contain what it traversed before the error - in my case, it only had Environment/Ferns, and, ie, nothing from Environment/Boardwalks, or anything else.
unity-sdk-1.0.0-preview.4 release OS: Windows 10 Unity: 2019.1.0b8
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
Hmm, which bug are you referring to? I actually just made a PR so USD can deal with TIF / JPG / etc (instead of just tif/jpg), is that what you’re referring to?
Anyway, that looks good, I’m going to close this issue! And thanks for this great plugin - other than this one small issue, it was amazingly simple and easy to use!
Took a look at MeshExporter.cs, and it looks like the check for
mesh == null
just needs to be moved up, before the check formesh.isReadable