Skip to content

Commit

Permalink
Merge pull request #1720 from ousttrue/feature/VRMBlendShapeProxy.Clear
Browse files Browse the repository at this point in the history
runtime に BlendShapeProxy.m_merger を再初期化する
  • Loading branch information
ousttrue committed Jun 29, 2022
2 parents 4659354 + 2f51b74 commit efdbef5
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions Assets/VRM/Runtime/BlendShape/VRMBlendShapeProxy.cs
Expand Up @@ -17,9 +17,10 @@ public void OnImported(VRMImporterContext context)
}

BlendShapeMerger m_merger;

bool m_destroyed = false;
private void OnDestroy()
{
m_destroyed = true;
if (m_merger != null)
{
m_merger.RestoreMaterialInitialValues(BlendShapeAvatar.Clips);
Expand All @@ -28,13 +29,25 @@ private void OnDestroy()

private void Start()
{
if (BlendShapeAvatar != null)
if (m_destroyed)
{
if (m_merger == null)
{
m_merger = new BlendShapeMerger(BlendShapeAvatar.Clips, transform);
}
return;
}
if (BlendShapeAvatar == null)
{
return;
}
// m_merger の null check は必用か?
m_merger = new BlendShapeMerger(BlendShapeAvatar.Clips, transform);
}

/// <summary>
/// m_merger を(再)作成する。
/// BlendShapeAvatar.Clips に対する変更を反映できます。
/// </summary>
public void Reinitialize()
{
Start();
}

/// <summary>
Expand Down

0 comments on commit efdbef5

Please sign in to comment.