From 3054eff5d76a5fc8d70569b0cb6c8d62222b1e04 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 19 May 2022 16:38:00 +0900 Subject: [PATCH] fix --- .../Editor/MeshUtility/GameObjectType.cs | 2 +- .../VRMMeshIntegratorUtility.cs | 8 --- .../SkinnedMeshUtility/VrmPrefabUtility.cs | 50 ------------------- .../VRM/Runtime/BlendShape/BlendShapeClip.cs | 2 +- 4 files changed, 2 insertions(+), 60 deletions(-) diff --git a/Assets/UniGLTF/Editor/MeshUtility/GameObjectType.cs b/Assets/UniGLTF/Editor/MeshUtility/GameObjectType.cs index 9199406e5..04acaa8d2 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/GameObjectType.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/GameObjectType.cs @@ -42,7 +42,7 @@ namespace UniGLTF.MeshUtility } else { - throw new System.Exception("unknown"); + throw new System.NotSupportedException("Unknown prefab status. The target does not exist in a valid scene and is not a prefab."); } } diff --git a/Assets/VRM/Editor/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs b/Assets/VRM/Editor/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs index 055e561c6..af74ab1bd 100644 --- a/Assets/VRM/Editor/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs +++ b/Assets/VRM/Editor/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs @@ -76,10 +76,6 @@ namespace VRM } Debug.Log(sb.ToString()); - // reload - // AssetDatabase.Refresh(); - // var clips = clipAssetPathList.Select(x => AssetDatabase.LoadAssetAtPath(x)).ToList(); - { // create blendshape avatar & replace var copy = ScriptableObject.CreateInstance(); @@ -87,10 +83,6 @@ namespace VRM var assetPath = $"{assetFolder}/blendshape.asset"; AssetDatabase.CreateAsset(copy, assetPath); - // reload - // AssetDatabase.Refresh(); - // blendShapeAvatar = AssetDatabase.LoadAssetAtPath(assetPath); - // assign proxy.BlendShapeAvatar = copy; } diff --git a/Assets/VRM/Editor/SkinnedMeshUtility/VrmPrefabUtility.cs b/Assets/VRM/Editor/SkinnedMeshUtility/VrmPrefabUtility.cs index 0f203752b..dd834276a 100644 --- a/Assets/VRM/Editor/SkinnedMeshUtility/VrmPrefabUtility.cs +++ b/Assets/VRM/Editor/SkinnedMeshUtility/VrmPrefabUtility.cs @@ -46,55 +46,5 @@ namespace VRM PrefabUtility.SaveAsPrefabAssetAndConnect(instance, path, InteractionMode.AutomatedAction); } - - /// - /// VRM prefab を ${prefab_dir}/MeshIntegratorBackup/ に複製する。 - /// - /// * prefab - /// * BlendShapeAvatar - /// * BlendShapeClip - /// - /// が複製される。 - /// - /// - public static void BackupVrmPrefab(GameObject go) - { - var prefab = go.GetGameObjectType() == GameObjectType.AssetPrefab ? go : PrefabUtility.GetCorrespondingObjectFromSource(go); - var prefabPath = UnityPath.FromAsset(prefab); - - var proxy = go.GetComponent(); - - var srcAvatar = proxy.BlendShapeAvatar; - var dstAvatar = (BlendShapeAvatar)BackupAsset(srcAvatar, prefabPath); - - var clipMapper = srcAvatar.Clips.ToDictionary(x => x, x => (BlendShapeClip)BackupAsset(x, prefabPath)); - dstAvatar.Clips = clipMapper.Values.ToList(); - - var dstPrefab = BackupAsset(prefab, prefabPath); - var dstInstance = InstantiatePrefab(dstPrefab); - dstInstance.GetComponent().BlendShapeAvatar = dstAvatar; - ApplyChangesToPrefab(dstInstance); - Object.DestroyImmediate(dstInstance); - } - - /// - /// asset を ${prefab_dir}/MeshIntegratorBackup/ にコピーし、コピーしたアセットをロードして返す - /// - /// - /// - /// - /// - private static T BackupAsset(T asset, UnityPath prefabPath) where T : UnityEngine.Object - { - var srcAssetPath = UnityPath.FromAsset(asset); - var assetName = srcAssetPath.FileName; - - var backupPath = prefabPath.Parent.Child(BACKUP_DIR); - backupPath.EnsureFolder(); - var dstAssetPath = backupPath.Child(assetName); - - AssetDatabase.CopyAsset(srcAssetPath.Value, dstAssetPath.Value); - return dstAssetPath.LoadAsset(); - } } } diff --git a/Assets/VRM/Runtime/BlendShape/BlendShapeClip.cs b/Assets/VRM/Runtime/BlendShape/BlendShapeClip.cs index a2ffc30b3..481383512 100644 --- a/Assets/VRM/Runtime/BlendShape/BlendShapeClip.cs +++ b/Assets/VRM/Runtime/BlendShape/BlendShapeClip.cs @@ -123,7 +123,7 @@ namespace VRM /// Preview 用のObject参照 /// [SerializeField] - public GameObject m_prefab; + GameObject m_prefab; public GameObject Prefab { set { m_prefab = value; }