modular-avatar/UnitTests~/ReactiveComponent/BlendshapeSyncTest.cs
kaikoga efa263b551
chore: Fix non-VRChat support (for MA 1.10.5) (#1324)
* feat: add version defines for VRCSDK

* chore: early return if VRCSDK project but not VRChat avatar
2024-10-27 10:06:35 -07:00

65 lines
2.0 KiB
C#

#if MA_VRCSDK3_AVATARS
using System.Linq;
using modular_avatar_tests;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using UnityEngine;
namespace UnitTests.ReactiveComponent
{
public class BlendshapeSyncTest : TestBase
{
[Test]
public void blendshapeSync_propagatesThroughMeshes()
{
var root = CreatePrefab("BlendshapeSyncTest.prefab");
var analysis = new ReactiveObjectAnalyzer().Analyze(root);
var m1 = analysis.Shapes[new TargetProp()
{
TargetObject = root.transform.Find("m1").GetComponent<SkinnedMeshRenderer>(),
PropertyName = "blendShape.bottom"
}];
var m2 = analysis.Shapes[new TargetProp()
{
TargetObject = root.transform.Find("m2").GetComponent<SkinnedMeshRenderer>(),
PropertyName = "blendShape.bottom"
}];
var m3 = analysis.Shapes[new TargetProp()
{
TargetObject = root.transform.Find("m3").GetComponent<SkinnedMeshRenderer>(),
PropertyName = "blendShape.top"
}];
Assert.IsTrue(analysis.Shapes.ContainsKey(new TargetProp()
{
TargetObject = root.transform.Find("m1").GetComponent<SkinnedMeshRenderer>(),
PropertyName = "deletedShape.bottom"
}));
Assert.AreEqual(4, analysis.Shapes.Count);
foreach (var ag in m1.actionGroups)
{
ag.TargetProp = new TargetProp();
}
foreach (var ag in m2.actionGroups)
{
ag.TargetProp = new TargetProp();
}
foreach (var ag in m3.actionGroups)
{
ag.TargetProp = new TargetProp();
}
Assert.AreEqual(m2.actionGroups, m1.actionGroups);
Assert.AreEqual(m3.actionGroups, m1.actionGroups);
}
}
}
#endif