From 04a1abab4ee17105f2da27fcac616d3d23e8ebf6 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 1 Nov 2018 15:55:18 +0900 Subject: [PATCH] BlendShapeClipHandler is obsolete --- Scripts/BlendShape/AIUEO.cs | 32 +++++++-------------- Scripts/BlendShape/BlendShapeClipHandler.cs | 7 +++-- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/Scripts/BlendShape/AIUEO.cs b/Scripts/BlendShape/AIUEO.cs index 92ade2c6e..02e1734f0 100644 --- a/Scripts/BlendShape/AIUEO.cs +++ b/Scripts/BlendShape/AIUEO.cs @@ -13,12 +13,6 @@ namespace VRM BlendShapes = GetComponent(); } - BlendShapeClipHandler m_appyerA; - BlendShapeClipHandler m_appyerI; - BlendShapeClipHandler m_appyerU; - BlendShapeClipHandler m_appyerE; - BlendShapeClipHandler m_appyerO; - Coroutine m_coroutine; [SerializeField] @@ -30,29 +24,23 @@ namespace VRM if (BlendShapes == null) return; if (BlendShapes.BlendShapeAvatar == null) return; var avatar = BlendShapes.BlendShapeAvatar; - - m_appyerA = new BlendShapeClipHandler(avatar.GetClip("A"), transform); - m_appyerI = new BlendShapeClipHandler(avatar.GetClip("I"), transform); - m_appyerU = new BlendShapeClipHandler(avatar.GetClip("U"), transform); - m_appyerE = new BlendShapeClipHandler(avatar.GetClip("E"), transform); - m_appyerO = new BlendShapeClipHandler(avatar.GetClip("O"), transform); } - static IEnumerator RoutineNest(BlendShapeClipHandler applyer, float velocity, float wait) + IEnumerator RoutineNest(BlendShapePreset preset, float velocity, float wait) { for (var value = 0.0f; value <= 1.0f; value += velocity) { - if (applyer != null) applyer.Apply(value); + BlendShapes.SetValue(preset, value); yield return null; } - if (applyer != null) applyer.Apply(1.0f); + BlendShapes.SetValue(preset, 1.0f); yield return new WaitForSeconds(wait); for (var value = 1.0f; value >= 0; value -= velocity) { - if (applyer != null) applyer.Apply(value); + BlendShapes.SetValue(preset, value); yield return null; } - if (applyer != null) applyer.Apply(0); + BlendShapes.SetValue(preset, 0); yield return new WaitForSeconds(wait * 2); } @@ -64,11 +52,11 @@ namespace VRM var velocity = 0.1f; - yield return RoutineNest(m_appyerA, velocity, m_wait); - yield return RoutineNest(m_appyerI, velocity, m_wait); - yield return RoutineNest(m_appyerU, velocity, m_wait); - yield return RoutineNest(m_appyerE, velocity, m_wait); - yield return RoutineNest(m_appyerO, velocity, m_wait); + yield return RoutineNest(BlendShapePreset.A, velocity, m_wait); + yield return RoutineNest(BlendShapePreset.I, velocity, m_wait); + yield return RoutineNest(BlendShapePreset.U, velocity, m_wait); + yield return RoutineNest(BlendShapePreset.E, velocity, m_wait); + yield return RoutineNest(BlendShapePreset.O, velocity, m_wait); } } diff --git a/Scripts/BlendShape/BlendShapeClipHandler.cs b/Scripts/BlendShape/BlendShapeClipHandler.cs index 964cf926c..03ab068f7 100644 --- a/Scripts/BlendShape/BlendShapeClipHandler.cs +++ b/Scripts/BlendShape/BlendShapeClipHandler.cs @@ -1,9 +1,10 @@ using UnityEngine; using System.Linq; - +using System; namespace VRM { + [Obsolete("Use VRMBlendShapeProxy")] public class BlendShapeClipHandler { BlendShapeClip m_clip; @@ -17,7 +18,7 @@ namespace VRM { m_clip = clip; - if (m_clip != null && m_clip.Values!=null && transform != null) + if (m_clip != null && m_clip.Values != null && transform != null) { m_renderers = m_clip.Values.Select(x => { @@ -45,7 +46,7 @@ namespace VRM { var binding = m_clip.Values[i]; var target = m_renderers[i]; - if(binding.Index>=0 && binding.Index < target.sharedMesh.blendShapeCount) + if (binding.Index >= 0 && binding.Index < target.sharedMesh.blendShapeCount) { target.SetBlendShapeWeight(binding.Index, binding.Weight * value); }