Load and assign VRMBlendShapeProxy.BlendShapeAvatar when importer avoid overwrite #142

This commit is contained in:
ousttrue
2019-01-26 17:18:36 +09:00
parent fcbea02954
commit 7a09b59307
2 changed files with 15 additions and 26 deletions

View File

@@ -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;

View File

@@ -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)