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

Unity2020.1系, Unity2019.3系でVRMファイルをインポートできない #321

Closed
yuma1217 opened this issue Oct 1, 2019 · 4 comments
Labels
bug Something isn't working importer
Milestone

Comments

@yuma1217
Copy link

yuma1217 commented Oct 1, 2019

バグについて

Unity2020.1.0a5や、Unity2019.3.0b3で、VRMファイルをインポートすると、
エラーをいくつか出し、PrefabにはMetaデータしか作成されない

再現方法

動作の再現させる手順:

  1. Unity2020.1系、Unity2019.3系で新規プロジェクトを作成
  2. UniVRM(UniVRM-0.53.0_6b07)をインポート
  3. 適当なVRMファイルをAsset内にドラッグアンドドロップ
  4. 作成されたPrefabとConsoleを見る

期待する動作

Metaデータのみではなく、VrmAvatar, AvatarDescriptionなども生成されてほしい
image

環境情報

  • OS: Windows10
  • UniVRM version: UniVRM-0.53.0_6b07

追加の状況・背景

コンソールに出たログです。

GetLoadedImportedAssetsAndTargetHashes called with invalid targetHash
UnityEditor.AssetDatabase:ImportAsset(String)
UniGLTF.UnityPath:ImportAsset() (at Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs:344)
UniGLTF.UnityPath:EnsureFolder() (at Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs:363)
UniGLTF.ImporterContext:SaveAsAsset(UnityPath) (at Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs:879)
VRM.<>c__DisplayClass1_0:<ImportVrm>b__0() (at Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs:52)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

Assertion failed on expression: 'it->second.IsValid()'
UnityEditor.AssetDatabase:ImportAsset(String)
UniGLTF.UnityPath:ImportAsset() (at Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs:344)
UniGLTF.UnityPath:EnsureFolder() (at Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs:363)
UniGLTF.ImporterContext:SaveAsAsset(UnityPath) (at Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs:879)
VRM.<>c__DisplayClass1_0:<ImportVrm>b__0() (at Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs:52)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

GetLoadedImportedAssetsAndTargetHashes called with invalid targetHash
UnityEditor.PrefabUtility:CreatePrefab(String, GameObject)
UniGLTF.ImporterContext:SaveAsAsset(UnityPath) (at Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs:900)
VRM.<>c__DisplayClass1_0:<ImportVrm>b__0() (at Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs:52)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

Assertion failed on expression: 'it->second.IsValid()'
UnityEditor.PrefabUtility:CreatePrefab(String, GameObject)
UniGLTF.ImporterContext:SaveAsAsset(UnityPath) (at Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs:900)
VRM.<>c__DisplayClass1_0:<ImportVrm>b__0() (at Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs:52)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

The asset is loaded, but not tracked. source hash='48175948448e7e1fb93a627af0888fa4'
UnityEditor.PrefabUtility:CreatePrefab(String, GameObject)
UniGLTF.ImporterContext:SaveAsAsset(UnityPath) (at Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs:900)
VRM.<>c__DisplayClass1_0:<ImportVrm>b__0() (at Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs:52)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

AssetImporter is referencing an asset from the previous import. This should not happen.
UnityEditor.PrefabUtility:CreatePrefab(String, GameObject)
UniGLTF.ImporterContext:SaveAsAsset(UnityPath) (at Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs:900)
VRM.<>c__DisplayClass1_0:<ImportVrm>b__0() (at Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs:52)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

AssetImporter is referencing an asset from the previous import. This should not happen.
UnityEditor.AssetDatabase:ImportAsset(String)
UniGLTF.UnityPath:ImportAsset() (at Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs:344)
UniGLTF.ImporterContext:SaveAsAsset(UnityPath) (at Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs:904)
VRM.<>c__DisplayClass1_0:<ImportVrm>b__0() (at Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs:52)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()
@yuma1217 yuma1217 changed the title Unity2020.1系, Unity2019.3系でVRMをインポートできない Unity2020.1系, Unity2019.3系でVRMファイルをインポートできない Oct 1, 2019
@ChrisFloofyKitsune
Copy link

ChrisFloofyKitsune commented Oct 4, 2019

It's something to do with the new experimental "Asset Pipeline v2" that Unity is testing out in their newest versions. It's a lot more picky and strange than the old version. It just doesn't like it when you try to do things to newly created assets such as saving them, importing them, or trying to assign references to them in other assets. I suspect it's trying to batch up any file changes for later and so the newly created things don't properly exist yet when they are used later in the code.

I managed to somewhat create a fix for the import issues by changing all occurrences of "PrefabUtility.ReplacePrefab" and "PrefabUtility.CreatePrefab" to "PrefabUtility.SaveAsPrefabAsset". Importing a fresh .vrm file will fail the first time, but then if you Reimport the file everything manages to load in correctly. (Though this was mainly inside the UniGLTF code part of it.) I think it's managing to work because it's only updating the prefab instead of trying to create it from scratch and so the subassets that reference things inside it are able to properly connect to it.

There will still be a lot of "Assertion failed on expression: 'serializedFileIndex != -1'" errors that pop up when things are saved or loaded, but it seems to simply be the new asset pipeline complaining instead of something seriously wrong.

(Interestingly enough, changing the file from a .vrm to a .glb works on it's first try also with a lot those errors.)

Here's a picture showing it working after a Reimport.
Capture

I suspect that to fix this problem, you will need to change the importing logic so that the creation and saving of the subassets waits until after the root prefab is saved at least once. To fix all the errors in their entirely might require a intenstive rewrite of the importer code to try and conform to the expectations of the new picky Asset Pipeline. (Or you could try to get Unity to fix things on their end by filing a bug report.)

I would do more but I honestly don't have the additional effort to spare.

@hiroj hiroj added bug Something isn't working importer labels Oct 8, 2019
@yuma1217
Copy link
Author

So thanks!
As you say, I changed asset pipe line ver1, importing works well!

@hiroj hiroj added this to the v0.54 milestone Nov 26, 2019
@hiroj
Copy link
Contributor

hiroj commented Dec 13, 2019

Fixed in v0.54 because there was an error in SubAssets of AssetPiplineV2.

@hiroj
Copy link
Contributor

hiroj commented Dec 18, 2019

https://github.com/vrm-c/UniVRM/releases/tag/v0.54.0
fixed version released.
If there is a problem, please report again with an issue.

@hiroj hiroj closed this as completed Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working importer
Projects
None yet
Development

No branches or pull requests

3 participants