keep prefab reference on BlendShapeClip

This commit is contained in:
ousttrue
2018-04-20 09:54:43 +09:00
parent ac55b6333b
commit 3dd41ce271
4 changed files with 40 additions and 17 deletions

View File

@@ -32,6 +32,7 @@ namespace VRM
Debug.LogFormat("{0}", path);
var clip = ScriptableObject.CreateInstance<BlendShapeClip>();
m_target.Clips.Add(clip);
clip.Prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GetAssetPath(m_target));
AssetDatabase.CreateAsset(clip, path);
AssetDatabase.ImportAsset(path);
}

View File

@@ -23,8 +23,14 @@ namespace VRM
BlendShapeClip m_target;
bool m_changed;
protected override GameObject GetPrefab()
{
return m_target.Prefab;
}
void OnPrefabChanged()
{
m_target.Prefab = Prefab;
Bake(m_target.Values, m_target.MaterialValues, 1.0f);
}

View File

@@ -40,10 +40,10 @@ namespace VRM
/// Previewシーンに表示するPrefab
/// </summary>
GameObject m_prefab;
GameObject Prefab
protected GameObject Prefab
{
get { return m_prefab; }
set
private set
{
if (m_prefab == value) return;
m_prefab = value;
@@ -89,15 +89,20 @@ namespace VRM
}
}
protected virtual GameObject GetPrefab()
{
var assetPath = AssetDatabase.GetAssetPath(target);
if (string.IsNullOrEmpty(assetPath))
{
return null;
}
return AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
}
protected virtual void OnEnable()
{
m_renderer = new PreviewFaceRenderer();
var assetPath = AssetDatabase.GetAssetPath(target);
//Debug.LogFormat("assetPath: {0}", assetPath);
if (!string.IsNullOrEmpty(assetPath))
{
Prefab = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
}
Prefab = GetPrefab();
}
protected virtual void OnDisable()