From e79400afa9c2a991cadeb46e1e0e5b0c314c1667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=C3=AF=7E?= Date: Wed, 4 Oct 2023 00:33:33 +0200 Subject: [PATCH] Add multi-blendshape --- .../V1/Editor/AacFlAnimations.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/AacFlAnimations.cs b/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/AacFlAnimations.cs index 6c7d334..a195262 100644 --- a/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/AacFlAnimations.cs +++ b/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/AacFlAnimations.cs @@ -87,6 +87,19 @@ namespace AnimatorAsCode.V1 return this; } + public AacFlClip BlendShape(SkinnedMeshRenderer[] rendererWithNulls, string blendShapeName, AnimationCurve animationCurve) + { + var defensiveObjects = rendererWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array + foreach (var component in defensiveObjects) + { + var binding = AacInternals.Binding(_component, typeof(SkinnedMeshRenderer), component.transform, $"blendShape.{blendShapeName}"); + + AacInternals.SetCurve(Clip, binding, animationCurve); + } + + return this; + } + public AacFlClip Positioning(GameObject[] gameObjectsWithNulls, Vector3 localPosition) { var defensiveObjects = gameObjectsWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array @@ -377,14 +390,14 @@ namespace AnimatorAsCode.V1 _bindings = bindings; } - public void WithOneFrame(Object objectReference) + public void WithOneFrame(Object desiredValue) { foreach (var binding in _bindings) { AnimationUtility.SetObjectReferenceCurve(_clip, binding, new[] { - new ObjectReferenceKeyframe { time = 0f, value = objectReference }, - new ObjectReferenceKeyframe { time = 1/60f, value = objectReference } + new ObjectReferenceKeyframe { time = 0f, value = desiredValue }, + new ObjectReferenceKeyframe { time = 1/60f, value = desiredValue } }); } }