Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime に BlendShapeProxy.m_merger を再初期化する #1720

Merged
merged 3 commits into from Jun 29, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion 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 @@ -37,6 +38,21 @@ private void Start()
}
}

/// <summary>
/// m_merger を(再)作成する。
/// BlendShapeAvatar.Clips に対する変更を反映できます。
/// </summary>
public void Restart()
{
if (BlendShapeAvatar != null)
{
if (!m_destroyed)
{
m_merger = new BlendShapeMerger(BlendShapeAvatar.Clips, transform);
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

変化が少なくなるように、 Clear をやめて Restart に変更しました。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reinitialize() などの方が命名としてはしっくりくるが、どうだろう。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/vrm-c/UniVRM/pull/1720/files#diff-21b8031f1a91629b829104f5142d6dd823982723e6e52be3f2bdc85dea128373R30-R39

と内容がほぼ同じ。ということは Start を呼ぶ関数にしよう 🤔

/// <summary>
/// Immediately SetValue
/// </summary>
Expand Down