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

UnityException: GUIDToAssetPath_Internal is not allowed to be called from a ScriptableObject constructor on entering play mode #30

Closed anatawa12 closed 2 months ago

anatawa12 commented 2 months ago

Describe the bug / バグの説明

UnityException: GUIDToAssetPath_Internal is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'PreviewPrefsUI'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEditor.AssetDatabase.GUIDToAssetPath_Internal (UnityEditor.GUID guid) <0x5310524c8 + 0x0003f> in <c8eeda6babdd44a1beef7ae3b1ac7095>:0
UnityEditor.AssetDatabase.GUIDToAssetPath (System.String guid) (at /Users/bokken/build/output/unity/unity/Modules/AssetDatabase/Editor/ScriptBindings/AssetDatabase.bindings.cs:351)
KRT.VRCQuestTools.Ndmf.VRCQuestToolsNdmfPlugin..cctor () (at ./Packages/com.github.kurotu.vrc-quest-tools/Editor/NDMF/VRCQuestToolsNdmfPlugin.cs:24)
Rethrow as TypeInitializationException: The type initializer for 'KRT.VRCQuestTools.Ndmf.VRCQuestToolsNdmfPlugin' threw an exception.
(wrapper write-barrier) System.Object.wbarrier_conc(intptr)
System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) (at <b904252b6b4e4277834bcca7e51f318d>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) (at <b904252b6b4e4277834bcca7e51f318d>:0)
System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <b904252b6b4e4277834bcca7e51f318d>:0)
System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <b904252b6b4e4277834bcca7e51f318d>:0)
System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) (at <b904252b6b4e4277834bcca7e51f318d>:0)
nadena.dev.ndmf.PluginResolver+<>c.<.ctor>b__5_0 (System.Type plugin) (at ./Packages/ndmf/Editor/API/Solver/PluginResolver.cs:72)
System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () (at <70b746ce69814738ab036ed807e71d03>:0)
nadena.dev.ndmf.PluginResolver..ctor (System.Collections.Generic.IEnumerable`1[T] pluginTemplates) (at ./Packages/ndmf/Editor/API/Solver/PluginResolver.cs:81)
nadena.dev.ndmf.PluginResolver..ctor (System.Collections.Generic.IEnumerable`1[T] plugins) (at ./Packages/ndmf/Editor/API/Solver/PluginResolver.cs:70)
nadena.dev.ndmf.PluginResolver..ctor () (at ./Packages/ndmf/Editor/API/Solver/PluginResolver.cs:60)
nadena.dev.ndmf.AvatarProcessor.ProcessAvatar (nadena.dev.ndmf.BuildContext buildContext, nadena.dev.ndmf.BuildPhase firstPhase, nadena.dev.ndmf.BuildPhase lastPhase) (at ./Packages/ndmf/Editor/AvatarProcessor.cs:183)
nadena.dev.ndmf.VRChat.BuildFrameworkPreprocessHook.OnPreprocessAvatar (UnityEngine.GameObject avatarGameObject) (at ./Packages/ndmf/Editor/VRChat/BuildFrameworkPreprocessHook.cs:43)
UnityEngine.Debug:LogException(Exception)
nadena.dev.ndmf.VRChat.BuildFrameworkPreprocessHook:OnPreprocessAvatar(GameObject) (at ./Packages/ndmf/Editor/VRChat/BuildFrameworkPreprocessHook.cs:48)
VRC.SDKBase.Editor.BuildPipeline.VRCBuildPipelineCallbacks:OnPreprocessAvatar(GameObject)
nadena.dev.ndmf.ApplyOnPlay:MaybeProcessAvatar(OnDemandSource, MonoBehaviour) (at ./Packages/ndmf/Editor/ApplyOnPlay.cs:98)
nadena.dev.ndmf.runtime.AvatarActivator:Awake() (at ./Packages/ndmf/Runtime/ApplyOnPlayGlobalActivator.cs:187)
UnityEngine.GameObject:AddComponent()
nadena.dev.ndmf.runtime.RuntimeUtil:GetOrAddComponent(GameObject) (at ./Packages/ndmf/Runtime/RuntimeUtil.cs:33)
nadena.dev.ndmf.runtime.ApplyOnPlayGlobalActivator:Awake() (at ./Packages/ndmf/Runtime/ApplyOnPlayGlobalActivator.cs:125)

がNDMFが有効なシーンを開いてPlayModeに入ると発生します。 VQTのコンポーネントをつけていなくても同様です スタックとーレースから推測するにAv3Emulatorが有効であると発生する問題の模様です

To Reproduce / 再現手順

  1. NDMFとVQTをインストールする
  2. 適当なアバターをシーンに置く
  3. Playモードに入る

Expected behavior / 期待する動作

エラーが発生しない

Screenshots / スクリーンショット

No response

Used assets / 使用したアセット

NDMF 1.5.0-rc.0 (commit 2dcca7626a7342896930e1fef549b5121df89e9b) VQT 2.4.2 AAO 開発版 他多数

VRCQuestTools version / VRCQuestToolsのバージョン

2.4.2

Unity version / Unityのバージョン

2022.3.22f1

Additional context / その他の情報

No response

anatawa12 commented 2 months ago

あー修正用にコードを見たら #29 で対応済で未リリースの模様でしたね。すみません。GUIDToAssetPath_Internalで検索して見つけられてませんでした