mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-08 20:08:53 -05:00
Load and assign VRMBlendShapeProxy.BlendShapeAvatar when importer avoid overwrite #142
This commit is contained in:
@@ -802,29 +802,13 @@ namespace UniGLTF
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsOverwrite(UnityEngine.Object o)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool LoadAsset(UnityPath assetPath, UnityEngine.Object o)
|
||||
public virtual bool AvoidOverwriteAndLoad(UnityPath assetPath, UnityEngine.Object o)
|
||||
{
|
||||
if (o is Material)
|
||||
{
|
||||
var loaded = assetPath.LoadAsset<Material>();
|
||||
|
||||
// replace member
|
||||
for(int i=0; i< m_materials.Count; ++i)
|
||||
{
|
||||
if (m_materials[i] == o)
|
||||
{
|
||||
m_materials[i] = loaded;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// replace renderers.material
|
||||
// replace component reference
|
||||
foreach(var mesh in Meshes)
|
||||
{
|
||||
foreach(var r in mesh.Renderers)
|
||||
@@ -874,7 +858,7 @@ namespace UniGLTF
|
||||
{
|
||||
if (assetPath.IsFileExists)
|
||||
{
|
||||
if (LoadAsset(assetPath, o))
|
||||
if (AvoidOverwriteAndLoad(assetPath, o))
|
||||
{
|
||||
// 上書きせずに既存のアセットからロードして置き換えた
|
||||
continue;
|
||||
|
||||
@@ -341,18 +341,23 @@ namespace VRM
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public override bool IsOverwrite(UnityEngine.Object o)
|
||||
public override bool AvoidOverwriteAndLoad(UnityPath assetPath, UnityEngine.Object o)
|
||||
{
|
||||
if (o is BlendShapeAvatar)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (o is BlendShapeClip)
|
||||
{
|
||||
return false;
|
||||
var loaded = assetPath.LoadAsset<BlendShapeAvatar>();
|
||||
var proxy = Root.GetComponent<VRMBlendShapeProxy>();
|
||||
proxy.BlendShapeAvatar = loaded;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.IsOverwrite(o);
|
||||
if (o is BlendShapeClip)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.AvoidOverwriteAndLoad(assetPath, o);
|
||||
}
|
||||
|
||||
protected override UnityPath GetAssetPath(UnityPath prefabPath, UnityEngine.Object o)
|
||||
|
||||
Reference in New Issue
Block a user