kurotu / VRCQuestTools

Unity editor extension to support uploading VRChat avatars for Oculus Quest
https://kurotu.github.io/VRCQuestTools/
MIT License
218 stars 15 forks source link

Conversion throws an NullReferenceException #16

Closed StevenKrahforst closed 9 months ago

StevenKrahforst commented 10 months ago

Describe the bug Just throws an Exception when trying to convert for Android

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Tools -> VRCQuestTools'
  2. Click on 'Convert Avatar for Android'
  3. Scroll down and then click 'Convert'
  4. See error

Expected behavior Just throws the Exception and nothing else happens

Screenshots image

Console log

NullReferenceException: Object reference not set to an instance of an object
KRT.VRCQuestTools.Utils.AssetUtility.SaveUncompressedTexture (System.String path, UnityEngine.Texture2D texture, System.Boolean isSRGB) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Utils/AssetUtility.cs:94)
KRT.VRCQuestTools.Models.ToonLitGenerator.GenerateToonLitTexture (KRT.VRCQuestTools.Models.Unity.MaterialBase material, KRT.VRCQuestTools.Models.IToonLitConvertSettings settings, System.String texturesPath) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/MaterialGenerators/ToonLitGenerator.cs:72)
KRT.VRCQuestTools.Models.ToonLitGenerator.GenerateMaterial (KRT.VRCQuestTools.Models.Unity.MaterialBase material, System.String texturesPath) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/MaterialGenerators/ToonLitGenerator.cs:32)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter.ConvertMaterialsForAndroid (UnityEngine.Material[] materials, KRT.VRCQuestTools.Components.AvatarConverterSettings avatarConverterSettings, System.String assetsDirectory, KRT.VRCQuestTools.Models.VRChat.AvatarConverter+TextureProgressCallback progressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:278)
--- End of stack trace from previous location where exception was thrown ---
KRT.VRCQuestTools.Models.VRChat.AvatarConverter.ConvertMaterialsForAndroid (UnityEngine.Material[] materials, KRT.VRCQuestTools.Components.AvatarConverterSettings avatarConverterSettings, System.String assetsDirectory, KRT.VRCQuestTools.Models.VRChat.AvatarConverter+TextureProgressCallback progressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:307)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter.ConvertForQuestImpl (KRT.VRCQuestTools.Models.VRChat.VRChatAvatar avatar, System.String assetsDirectory, KRT.VRCQuestTools.Models.ComponentRemover remover, KRT.VRCQuestTools.Components.AvatarConverterSettings setting, KRT.VRCQuestTools.Models.VRChat.AvatarConverter+ProgressCallback progressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:88)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter.ConvertForQuest (KRT.VRCQuestTools.Components.AvatarConverterSettings avatarConverterSettings, System.String assetsDirectory, KRT.VRCQuestTools.Models.ComponentRemover remover, KRT.VRCQuestTools.Models.VRChat.AvatarConverter+ProgressCallback progressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:66)
KRT.VRCQuestTools.Inspector.AvatarConverterSettingsEditor.OnClickConvertButton (VRC.SDKBase.VRC_AvatarDescriptor avatar) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Inspector/AvatarConverterSettingsEditor.cs:492)
KRT.VRCQuestTools.Inspector.AvatarConverterSettingsEditor.OnInspectorGUI () (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Inspector/AvatarConverterSettingsEditor.cs:328)
KRT.VRCQuestTools.Views.AvatarConverterWindow.OnGUI () (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Views/AvatarConverterWindow.cs:90)
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 <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.ProcessEvent (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <4397ca26b8a24183a25a95ffae967e39>:0)

Used assets

Environment

Additional context None

kurotu commented 10 months ago

It seems that somehow a texture is not generated (but why?). Can I reproduce the issue just by using Taidum avatar?

And for now, you can disable Generate Textures for Android option of VQT Avatar Converter Settings component as a workaround.

StevenKrahforst commented 10 months ago

Lmao, it throws a different Exception then

image image

Parent directory must exist before creating asset at Assets/VRCQuestToolsOutput/IrixTaidum3 /Materials/Material_from_a9c0a11da15935345a72658ba00f4667.mat.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
KRT.VRCQuestTools.Utils.AssetUtility:CreateAsset<UnityEngine.Material> (UnityEngine.Material,string) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Utils/AssetUtility.cs:300)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter:ConvertMaterialsForAndroid (UnityEngine.Material[],KRT.VRCQuestTools.Components.AvatarConverterSettings,string,KRT.VRCQuestTools.Models.VRChat.AvatarConverter/TextureProgressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:299)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter:ConvertForQuestImpl (KRT.VRCQuestTools.Models.VRChat.VRChatAvatar,string,KRT.VRCQuestTools.Models.ComponentRemover,KRT.VRCQuestTools.Components.AvatarConverterSettings,KRT.VRCQuestTools.Models.VRChat.AvatarConverter/ProgressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:88)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter:ConvertForQuest (KRT.VRCQuestTools.Components.AvatarConverterSettings,string,KRT.VRCQuestTools.Models.ComponentRemover,KRT.VRCQuestTools.Models.VRChat.AvatarConverter/ProgressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:66)
KRT.VRCQuestTools.Inspector.AvatarConverterSettingsEditor:OnClickConvertButton (VRC.SDKBase.VRC_AvatarDescriptor) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Inspector/AvatarConverterSettingsEditor.cs:492)
KRT.VRCQuestTools.Inspector.AvatarConverterSettingsEditor:OnInspectorGUI () (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Inspector/AvatarConverterSettingsEditor.cs:328)
KRT.VRCQuestTools.Views.AvatarConverterWindow:OnGUI () (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Views/AvatarConverterWindow.cs:90)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
UnityException: Creating asset at path Assets/VRCQuestToolsOutput/IrixTaidum3 /Materials/Material_from_a9c0a11da15935345a72658ba00f4667.mat failed.
KRT.VRCQuestTools.Utils.AssetUtility.CreateAsset[T] (T asset, System.String path) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Utils/AssetUtility.cs:300)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter.ConvertMaterialsForAndroid (UnityEngine.Material[] materials, KRT.VRCQuestTools.Components.AvatarConverterSettings avatarConverterSettings, System.String assetsDirectory, KRT.VRCQuestTools.Models.VRChat.AvatarConverter+TextureProgressCallback progressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:299)
--- End of stack trace from previous location where exception was thrown ---
KRT.VRCQuestTools.Models.VRChat.AvatarConverter.ConvertMaterialsForAndroid (UnityEngine.Material[] materials, KRT.VRCQuestTools.Components.AvatarConverterSettings avatarConverterSettings, System.String assetsDirectory, KRT.VRCQuestTools.Models.VRChat.AvatarConverter+TextureProgressCallback progressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:307)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter.ConvertForQuestImpl (KRT.VRCQuestTools.Models.VRChat.VRChatAvatar avatar, System.String assetsDirectory, KRT.VRCQuestTools.Models.ComponentRemover remover, KRT.VRCQuestTools.Components.AvatarConverterSettings setting, KRT.VRCQuestTools.Models.VRChat.AvatarConverter+ProgressCallback progressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:88)
KRT.VRCQuestTools.Models.VRChat.AvatarConverter.ConvertForQuest (KRT.VRCQuestTools.Components.AvatarConverterSettings avatarConverterSettings, System.String assetsDirectory, KRT.VRCQuestTools.Models.ComponentRemover remover, KRT.VRCQuestTools.Models.VRChat.AvatarConverter+ProgressCallback progressCallback) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/VRChat/AvatarConverter.cs:66)
KRT.VRCQuestTools.Inspector.AvatarConverterSettingsEditor.OnClickConvertButton (VRC.SDKBase.VRC_AvatarDescriptor avatar) (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Inspector/AvatarConverterSettingsEditor.cs:492)
KRT.VRCQuestTools.Inspector.AvatarConverterSettingsEditor.OnInspectorGUI () (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Inspector/AvatarConverterSettingsEditor.cs:328)
KRT.VRCQuestTools.Views.AvatarConverterWindow.OnGUI () (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/Views/AvatarConverterWindow.cs:90)
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 <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.ProcessEvent (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <4397ca26b8a24183a25a95ffae967e39>:0)
kurotu commented 10 months ago

It's no laughing matter for me. I would like you to follow my requests because I need your cooperation to solve your issue. For example,

Anyway, I tried Assets/IrixTadium3.0/IrixTaidum3.prefab. The cause is that the prefab's object name is ended with a whitespace (IrixTaidum3). So you can remove trailing whitespaces as a workaround for now.

StevenKrahforst commented 10 months ago

I've created a brand-new project and it looks like none of the assets are the reason, I only imported the Taidum and poi_Pro_9.0.22_Only and changed the Shader for the 3 Materials to Poiyomi Pro.

When I then tried to convert it, the same Exception will be thrown. But if I switch back from Poiyomi Pro to the Mobile Toon Lit Shader the error is gone.

So I think it would also apply to different Avatars and not only the Taidum. And the workaround actually works and fixes everything.

kurotu commented 9 months ago

Fixed by v2.2.0.