From c379d730ca5d1a02df26605497984fc594df2832 Mon Sep 17 00:00:00 2001 From: bd_ Date: Wed, 2 Oct 2024 20:09:14 -0700 Subject: [PATCH] chore: fix unit test broken by merge --- .../InitialStates/SCDefaultAnimation.cs | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.cs b/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.cs index 8a3f9ad6..c1061b3e 100644 --- a/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.cs +++ b/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.cs @@ -20,7 +20,50 @@ namespace ShapeChangerTests [Test] public void SetsCorrectInitialStatesAndAnimationsForInactiveSC() { - SetsCorrectInitialStatesAndAnimations("SCDefaultAnimationInactive.prefab"); + var root = CreatePrefab("SCDefaultAnimationInactive.prefab"); + AvatarProcessor.ProcessAvatar(root); + + var fx = (AnimatorController) FindFxController(root).animatorController; + var baseLayer = fx.layers[0]; + + var bt = baseLayer.stateMachine.states[0].state.motion as BlendTree; + Assert.NotNull(bt); + var subBt = bt.children[0].motion as BlendTree; + Assert.NotNull(subBt); + var clip = subBt.children[0].motion as AnimationClip; + Assert.NotNull(clip); + + var smr = root.transform.Find("test mesh").GetComponent(); + var sharedMesh = smr.sharedMesh; + + var bindings = AnimationUtility.GetCurveBindings(clip); + var curve = AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve( + "test mesh", + typeof(SkinnedMeshRenderer), + "blendShape.key1" + )); + Assert.IsNull(curve); // always off MenuItem (due to object disable), no curve should be generated + + curve = AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve( + "test mesh", + typeof(SkinnedMeshRenderer), + "blendShape.key2" + )); + // Always-on delete, no curve should be generated + Assert.IsNull(curve); + + curve = AnimationUtility.GetEditorCurve(clip, EditorCurveBinding.FloatCurve( + "test mesh", + typeof(SkinnedMeshRenderer), + "blendShape.key3" + )); + // Always-on set, no curve should be generated + Assert.IsNull(curve); + + // Check actual blendshape states + Assert.AreEqual(10.0f, smr.GetBlendShapeWeight(sharedMesh.GetBlendShapeIndex("key1")), 0.1f); + Assert.AreEqual(5.0f, smr.GetBlendShapeWeight(sharedMesh.GetBlendShapeIndex("key2")), 0.1f); + Assert.AreEqual(100.0f, smr.GetBlendShapeWeight(sharedMesh.GetBlendShapeIndex("key3")), 0.1f); } [Test]