vrm-c / UniVRM

UniVRM is a gltf-based VRM format implementation for Unity. English is here https://vrm.dev/en/ . 日本語 はこちら https://vrm.dev/
https://vrm.dev/en
MIT License
2.64k stars 424 forks source link

[MeshAttachInfo.cs:23] Null reference exeption on 2022.3.6f1 #2206

Closed Fondersonic closed 4 months ago

Fondersonic commented 10 months ago

Environments (please complete the following information):

Describe the bug

i try to export an model and it dont send nothing to the folder and i get this error:

NullReferenceException: Object reference not set to an instance of an object UniGLTF.MeshUtility.MeshAttachInfo+<>c__DisplayClass4_0.b0 (UnityEngine.Transform x) (at Assets/UniGLTF/Runtime/MeshUtility/MeshAttachInfo.cs:23) System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToArray () (at <de4a1a1490a74771a34fee0d1d586658>:0) System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable1[T] source) (at :0) UniGLTF.MeshUtility.MeshAttachInfo.ReplaceMesh (UnityEngine.GameObject dst) (at Assets/UniGLTF/Runtime/MeshUtility/MeshAttachInfo.cs:23) UniGLTF.MeshUtility.BoneNormalizer.Replace (UnityEngine.GameObject go, System.Collections.Generic.Dictionary2[TKey,TValue] meshMap, System.Boolean FreezeRotation, System.Boolean FreezeScaling) (at Assets/UniGLTF/Runtime/MeshUtility/BoneNormalizer.cs:106) VRM.VRMBoneNormalizer.Execute (UnityEngine.GameObject go, System.Boolean forceTPose) (at Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs:72) VRM.VRMEditorExporter.Export (UnityEngine.GameObject exportRoot, VRM.VRMMetaObject meta, VRM.VRMExportSettings settings, System.Collections.Generic.List1[T] destroy) (at Assets/VRM/Editor/Format/VRMEditorExporter.cs:206) VRM.VRMEditorExporter.Export (UnityEngine.GameObject exportRoot, VRM.VRMMetaObject meta, VRM.VRMExportSettings settings) (at Assets/VRM/Editor/Format/VRMEditorExporter.cs:25) VRM.VRMExporterWizard.ExportPath (System.String path) (at Assets/VRM/Editor/Format/VRMExporterWizard.cs:264) UniGLTF.ExportDialogBase.EndGUI () (at Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs:162) UniGLTF.ExportDialogBase.OnGUI () (at Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs:82) UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at <347e3e2bef8c4deb82c9790c6e198135>:0) UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at <347e3e2bef8c4deb82c9790c6e198135>:0) UnityEditor.DockArea.OldOnGUI () (at <347e3e2bef8c4deb82c9790c6e198135>:0) UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at :0) UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at :0) UnityEngine.UIElements.IMGUIContainer.ProcessEvent (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at :0) UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at :0) UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at :0) UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at :0) UnityEngine.UIElements.EventDispatcher.OpenGate () (at :0) UnityEngine.UIElements.EventDispatcherGate.Dispose () (at :0) UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at :0) UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at :0) UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at :0) UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at :0) UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at :0) UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at :0) UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b1_2 (System.Int32 i, System.IntPtr ptr) (at :0) UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <4397ca26b8a24183a25a95ffae967e39>:0)

VentusTheSox commented 9 months ago

Same issue, using unity 2022.3.6f1 and univrm 0.118.0_226d

NullReferenceException: Object reference not set to an instance of an object UniVRM10.ModelExporter+<>c__DisplayClass10_0.b__0 (UnityEngine.Transform x) (at Assets/VRM10/Runtime/IO/Model/ModelExporter.cs:306) System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToList () (at <de4a1a1490a74771a34fee0d1d586658>:0) System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable1[T] source) (at :0) UniVRM10.ModelExporter.CreateSkin (UniGLTF.INativeArrayManager arrayManager, UnityEngine.SkinnedMeshRenderer skinnedMeshRenderer, System.Collections.Generic.Dictionary`2[TKey,TValue] nodes, UnityEngine.GameObject root) (at Assets/VRM10/Runtime/IO/Model/ModelExporter.cs:306) UniVRM10.ModelExporter._Export (UniGLTF.INativeArrayManager arrayManager, UnityEngine.GameObject root) (at Assets/VRM10/Runtime/IO/Model/ModelExporter.cs:135) UniVRM10.ModelExporter.Export (UniGLTF.INativeArrayManager arrayManager, UnityEngine.GameObject root) (at Assets/VRM10/Runtime/IO/Model/ModelExporter.cs:31) UniVRM10.VRM10ExportDialog.ExportPath (System.String path) (at Assets/VRM10/Editor/Vrm10ExportDialog.cs:274) UnityEngine.Debug:LogException(Exception) UniVRM10.VRM10ExportDialog:ExportPath(String) (at Assets/VRM10/Editor/Vrm10ExportDialog.cs:307) UniGLTF.ExportDialogBase:EndGUI() (at Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs:162) UniGLTF.ExportDialogBase:OnGUI() (at Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs:82) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

image

mishkavrc commented 9 months ago

Same issue as both above. UniVRM: v0.118.0 Unity version: 2022.3.6f1 Windows version: 10

NullReferenceException: Object reference not set to an instance of an object UniGLTF.MeshUtility.MeshAttachInfo+<>c__DisplayClass4_0.b0 (UnityEngine.Transform x) (at Assets/UniGLTF/Runtime/MeshUtility/MeshAttachInfo.cs:23) System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToArray () (at <de4a1a1490a74771a34fee0d1d586658>:0) System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable1[T] source) (at :0) UniGLTF.MeshUtility.MeshAttachInfo.ReplaceMesh (UnityEngine.GameObject dst) (at Assets/UniGLTF/Runtime/MeshUtility/MeshAttachInfo.cs:23) UniGLTF.MeshUtility.BoneNormalizer.Replace (UnityEngine.GameObject go, System.Collections.Generic.Dictionary2[TKey,TValue] meshMap, System.Boolean FreezeRotation, System.Boolean FreezeScaling) (at Assets/UniGLTF/Runtime/MeshUtility/BoneNormalizer.cs:106) VRM.VRMBoneNormalizer.Execute (UnityEngine.GameObject go, System.Boolean forceTPose) (at Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs:84) VRM.VRMEditorExporter.Export (UnityEngine.GameObject exportRoot, VRM.VRMMetaObject meta, VRM.VRMExportSettings settings, System.Collections.Generic.List1[T] destroy) (at Assets/VRM/Editor/Format/VRMEditorExporter.cs:205) VRM.VRMEditorExporter.Export (UnityEngine.GameObject exportRoot, VRM.VRMMetaObject meta, VRM.VRMExportSettings settings) (at Assets/VRM/Editor/Format/VRMEditorExporter.cs:25) VRM.VRMExporterWizard.ExportPath (System.String path) (at Assets/VRM/Editor/Format/VRMExporterWizard.cs:264) UniGLTF.ExportDialogBase.EndGUI () (at Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs:162) UniGLTF.ExportDialogBase.OnGUI () (at Assets/UniGLTF/Editor/UniGLTF/ExportDialog/ExportDialogBase.cs:82) UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at <347e3e2bef8c4deb82c9790c6e198135>:0) UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at <347e3e2bef8c4deb82c9790c6e198135>:0) UnityEditor.DockArea.OldOnGUI () (at <347e3e2bef8c4deb82c9790c6e198135>:0) UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at :0) UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at :0) UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at :0) UnityEngine.UIElements.IMGUIContainer.ProcessEvent (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at :0) UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at :0) UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at :0) UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at :0) UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at :0) UnityEngine.UIElements.EventDispatcher.OpenGate () (at :0) UnityEngine.UIElements.EventDispatcherGate.Dispose () (at :0) UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at :0) UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at :0) UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at :0) UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at :0) UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at :0) UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at :0) UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b1_2 (System.Int32 i, System.IntPtr ptr) (at :0) UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <4397ca26b8a24183a25a95ffae967e39>:0)

Katinor commented 9 months ago

Same issue as both above. UniVRM: v0.118.0 Unity version: 2021.3.35f1 Windows version: 11

This is also happened in 2021.3 LTS, which is mentioned as required version.

스크린샷 2024-02-08 002229

Pacmard commented 8 months ago

Having same issue on v0.119, I guess its a subject to be fixed in 0.120? Any workaround for now?

ousttrue commented 8 months ago

Thank you for your report

at Assets/UniGLTF/Runtime/MeshUtility/MeshAttachInfo.cs:23

Mesh.bindposes = Bones.Select(x => x.worldToLocalMatrix * dst.transform.localToWorldMatrix).ToArray();

Has the gameobject used for skinning been deleted?

workaround

Please try disable instead of remove.

at Assets/VRM10/Runtime/IO/Model/ModelExporter.cs:306

skin.Joints = skinnedMeshRenderer.bones.Select(x => nodes[x.gameObject]).ToList();

Has the gameobject used for skinning been deleted?

workaround

Please try disable instead of remove.

Katinor commented 8 months ago

Tested again. Same issue in v.0.119.0 Unity version: 2022.3.6f1

Exporting VRM by using object imported from VRM was fine. Issues above are only when I make VRM from first.

Deleting Skinned Mesh Renderer didn't affect. It caused an error when I deleted bones (GameObjects under armature).

v.0.112.0 didn't have this issue.

Using several assets is normal during making an avatar, and deleting GameObjects with Renderer or under armature happens often for optimization and production convenience because not all components are necessary. Please reconsider this issue.

Pacmard commented 8 months ago

Thank you for your report

at Assets/UniGLTF/Runtime/MeshUtility/MeshAttachInfo.cs:23

Mesh.bindposes = Bones.Select(x => x.worldToLocalMatrix * dst.transform.localToWorldMatrix).ToArray();

Has the gameobject used for skinning been deleted?

workaround

Please try disable instead of remove.

at Assets/VRM10/Runtime/IO/Model/ModelExporter.cs:306

skin.Joints = skinnedMeshRenderer.bones.Select(x => nodes[x.gameObject]).ToList();

Has the gameobject used for skinning been deleted?

workaround

Please try disable instead of remove.

I was performing testing on the unedited avatar prefab, so nothing was disabled or deleted, hence I don't know where this comes from.

Using some older versions works just fine

xXDerpyXx commented 7 months ago

Thank you for your report

at Assets/UniGLTF/Runtime/MeshUtility/MeshAttachInfo.cs:23

Mesh.bindposes = Bones.Select(x => x.worldToLocalMatrix * dst.transform.localToWorldMatrix).ToArray();

Has the gameobject used for skinning been deleted?

workaround

Please try disable instead of remove.

at Assets/VRM10/Runtime/IO/Model/ModelExporter.cs:306

skin.Joints = skinnedMeshRenderer.bones.Select(x => nodes[x.gameObject]).ToList();

Has the gameobject used for skinning been deleted?

workaround

Please try disable instead of remove.

I was performing testing on the unedited avatar prefab, so nothing was disabled or deleted, hence I don't know where this comes from.

Using some older versions works just fine

I'm having the exact same error on a fresh prefab as well.

why should it matter anyways? shouldn't it be able to see that some reference is missing and ignore it like any other unity exporter tool, VRchat's SDK does for example. I may try to edit the code myself and see what I can come up with, but it's been years since I've done C#, so don't wait on me.

ousttrue commented 4 months ago

2326

ousttrue commented 4 months ago

This issue is expected to be exportable in v0.124.1.