From b05a51c02cf572ab1cf4566c372a01d979b4ce2a Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 19 Dec 2018 16:49:38 +0900 Subject: [PATCH] Restore BlendShapeClip.Apply --- Scripts/BlendShape/BlendShapeClip.cs | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Scripts/BlendShape/BlendShapeClip.cs b/Scripts/BlendShape/BlendShapeClip.cs index 4b883fdc4..6f3a5f3a2 100644 --- a/Scripts/BlendShape/BlendShapeClip.cs +++ b/Scripts/BlendShape/BlendShapeClip.cs @@ -58,6 +58,50 @@ namespace VRM return m_prefab; } } + + /// + /// Apply BlendShape for Preview + /// + /// + /// + public void Apply(Transform root, float value) + { + if (Values != null) + { + foreach (var x in Values) + { + var target = root.Find(x.RelativePath); + if (target != null) + { + var sr = target.GetComponent(); + if (sr != null) + { + sr.SetBlendShapeWeight(x.Index, x.Weight * value); + } + } + } + } + + /* + if (MaterialValues != null) + { + foreach (var x in MaterialValues) + { + var target = root.Find(x.RelativePath); + if (target != null) + { + var sr = target.GetComponent(); + if (sr != null) + { + var m = sr.sharedMaterials[x.Index]; + var color = x.BaseValue + (x.TargetValue - x.BaseValue) * value; + m.SetColor(x.ValueName, color); + } + } + } + } + */ + } #endif ///