mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-11 04:54:17 -05:00
keep prefab reference on BlendShapeClip
This commit is contained in:
parent
ac55b6333b
commit
3dd41ce271
|
|
@ -24,6 +24,26 @@ namespace VRM
|
|||
[CreateAssetMenu(menuName = "VRM/BlendShapeClip")]
|
||||
public class BlendShapeClip : ScriptableObject
|
||||
{
|
||||
[SerializeField]
|
||||
GameObject m_prefab;
|
||||
public GameObject Prefab
|
||||
{
|
||||
set { m_prefab = value; }
|
||||
get {
|
||||
#if UNITY_EDITOR
|
||||
if (m_prefab == null)
|
||||
{
|
||||
var assetPath = UnityEditor.AssetDatabase.GetAssetPath(this);
|
||||
if (!string.IsNullOrEmpty(assetPath))
|
||||
{
|
||||
m_prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return m_prefab;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
public string BlendShapeName = "";
|
||||
|
||||
|
|
@ -74,14 +94,5 @@ namespace VRM
|
|||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static BlendShapeClip Create(BlendShapePreset preset)
|
||||
{
|
||||
var clip = ScriptableObject.CreateInstance<BlendShapeClip>();
|
||||
clip.Preset = preset;
|
||||
clip.BlendShapeName = preset.ToString();
|
||||
clip.name = preset.ToString();
|
||||
return clip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user