mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-06-02 22:14:30 -05:00
fix
This commit is contained in:
parent
facbf1f874
commit
3054eff5d7
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,10 +76,6 @@ namespace VRM
|
|||
}
|
||||
Debug.Log(sb.ToString());
|
||||
|
||||
// reload
|
||||
// AssetDatabase.Refresh();
|
||||
// var clips = clipAssetPathList.Select(x => AssetDatabase.LoadAssetAtPath<BlendShapeClip>(x)).ToList();
|
||||
|
||||
{
|
||||
// create blendshape avatar & replace
|
||||
var copy = ScriptableObject.CreateInstance<BlendShapeAvatar>();
|
||||
|
|
@ -87,10 +83,6 @@ namespace VRM
|
|||
var assetPath = $"{assetFolder}/blendshape.asset";
|
||||
AssetDatabase.CreateAsset(copy, assetPath);
|
||||
|
||||
// reload
|
||||
// AssetDatabase.Refresh();
|
||||
// blendShapeAvatar = AssetDatabase.LoadAssetAtPath<BlendShapeAvatar>(assetPath);
|
||||
|
||||
// assign
|
||||
proxy.BlendShapeAvatar = copy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,55 +46,5 @@ namespace VRM
|
|||
|
||||
PrefabUtility.SaveAsPrefabAssetAndConnect(instance, path, InteractionMode.AutomatedAction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// VRM prefab を ${prefab_dir}/MeshIntegratorBackup/ に複製する。
|
||||
///
|
||||
/// * prefab
|
||||
/// * BlendShapeAvatar
|
||||
/// * BlendShapeClip
|
||||
///
|
||||
/// が複製される。
|
||||
/// </summary>
|
||||
/// <param name="go"></param>
|
||||
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<VRMBlendShapeProxy>();
|
||||
|
||||
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<VRMBlendShapeProxy>().BlendShapeAvatar = dstAvatar;
|
||||
ApplyChangesToPrefab(dstInstance);
|
||||
Object.DestroyImmediate(dstInstance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// asset を ${prefab_dir}/MeshIntegratorBackup/ にコピーし、コピーしたアセットをロードして返す
|
||||
/// </summary>
|
||||
/// <param name="asset"></param>
|
||||
/// <param name="rootPrefab"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
private static T BackupAsset<T>(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<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ namespace VRM
|
|||
/// Preview 用のObject参照
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public GameObject m_prefab;
|
||||
GameObject m_prefab;
|
||||
public GameObject Prefab
|
||||
{
|
||||
set { m_prefab = value; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user