mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
chore: Add TransformMappingThroughSwitchedObject test
This commit is contained in:
parent
f64f00e2d3
commit
c3e0f94448
@ -20,21 +20,9 @@ namespace modular_avatar_tests.AnimateAddedBones
|
|||||||
var prefab = CreatePrefab("AnimateAddedBones.prefab");
|
var prefab = CreatePrefab("AnimateAddedBones.prefab");
|
||||||
AvatarProcessor.ProcessAvatar(prefab);
|
AvatarProcessor.ProcessAvatar(prefab);
|
||||||
|
|
||||||
var fx = prefab.GetComponent<VRCAvatarDescriptor>().baseAnimationLayers
|
var layerName = "merged";
|
||||||
.FirstOrDefault(l => l.type == VRCAvatarDescriptor.AnimLayerType.FX);
|
|
||||||
|
|
||||||
Assert.NotNull(fx);
|
var motion = findFxMotion(prefab, layerName);
|
||||||
var ac = fx.animatorController as AnimatorController;
|
|
||||||
Assert.NotNull(ac);
|
|
||||||
Assert.False(fx.isDefault);
|
|
||||||
|
|
||||||
var layer = ac.layers.FirstOrDefault(l => l.name == "merged");
|
|
||||||
Assert.NotNull(layer);
|
|
||||||
var state = layer.stateMachine.states[0].state;
|
|
||||||
Assert.NotNull(state);
|
|
||||||
|
|
||||||
var motion = state.motion as AnimationClip;
|
|
||||||
Assert.NotNull(motion);
|
|
||||||
|
|
||||||
var cubeObject = prefab.transform.Find("Armature/Hips").GetChild(0).gameObject;
|
var cubeObject = prefab.transform.Find("Armature/Hips").GetChild(0).gameObject;
|
||||||
Assert.True(cubeObject.name.StartsWith("Cube$"));
|
Assert.True(cubeObject.name.StartsWith("Cube$"));
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using nadena.dev.modular_avatar.core.editor;
|
using nadena.dev.modular_avatar.core.editor;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditor.Animations;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VRC.SDK3.Avatars.Components;
|
using VRC.SDK3.Avatars.Components;
|
||||||
|
|
||||||
@ -61,5 +63,32 @@ namespace modular_avatar_tests
|
|||||||
objects.Add(go);
|
objects.Add(go);
|
||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected static AnimationClip findFxMotion(GameObject prefab, string layerName)
|
||||||
|
{
|
||||||
|
var layer = findFxLayer(prefab, layerName);
|
||||||
|
var state = layer.stateMachine.states[0].state;
|
||||||
|
Assert.NotNull(state);
|
||||||
|
|
||||||
|
var motion = state.motion as AnimationClip;
|
||||||
|
Assert.NotNull(motion);
|
||||||
|
return motion;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static AnimatorControllerLayer findFxLayer(GameObject prefab, string layerName)
|
||||||
|
{
|
||||||
|
var fx = prefab.GetComponent<VRCAvatarDescriptor>().baseAnimationLayers
|
||||||
|
.FirstOrDefault(l => l.type == VRCAvatarDescriptor.AnimLayerType.FX);
|
||||||
|
|
||||||
|
Assert.NotNull(fx);
|
||||||
|
var ac = fx.animatorController as AnimatorController;
|
||||||
|
Assert.NotNull(ac);
|
||||||
|
Assert.False(fx.isDefault);
|
||||||
|
|
||||||
|
var layer = ac.layers.FirstOrDefault(l => l.name == layerName);
|
||||||
|
Assert.NotNull(layer);
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ AnimatorStateMachine:
|
|||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: Base Layer
|
m_Name: child_controller
|
||||||
m_ChildStates:
|
m_ChildStates:
|
||||||
- serializedVersion: 1
|
- serializedVersion: 1
|
||||||
m_State: {fileID: 4610933037596458320}
|
m_State: {fileID: 4610933037596458320}
|
||||||
@ -33,7 +33,7 @@ AnimatorController:
|
|||||||
m_AnimatorParameters: []
|
m_AnimatorParameters: []
|
||||||
m_AnimatorLayers:
|
m_AnimatorLayers:
|
||||||
- serializedVersion: 5
|
- serializedVersion: 5
|
||||||
m_Name: Base Layer
|
m_Name: child_controller
|
||||||
m_StateMachine: {fileID: -7544367895585285567}
|
m_StateMachine: {fileID: -7544367895585285567}
|
||||||
m_Mask: {fileID: 0}
|
m_Mask: {fileID: 0}
|
||||||
m_Motions: []
|
m_Motions: []
|
@ -0,0 +1,27 @@
|
|||||||
|
using nadena.dev.modular_avatar.core.editor;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace modular_avatar_tests.TransformMappingThroughSwitchedObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This test verifies that transform mappings are properly handled, even if the bone they target is on an armature
|
||||||
|
/// underneath multiple switched objects (which therefore would generate multiple levels of proxy switch objects).
|
||||||
|
/// </summary>
|
||||||
|
public class TransformMappingThroughSwitchedObject : TestBase
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TransformMappingHandledCorrectly()
|
||||||
|
{
|
||||||
|
var prefab = CreatePrefab("TransformMappingThroughSwitchedObject.prefab");
|
||||||
|
AvatarProcessor.ProcessAvatar(prefab);
|
||||||
|
|
||||||
|
var motion = findFxMotion(prefab, "child_controller");
|
||||||
|
|
||||||
|
var binding = EditorCurveBinding.FloatCurve("Armature/Hips", typeof(Transform), "localEulerAnglesRaw.x");
|
||||||
|
var curve = AnimationUtility.GetEditorCurve(motion, binding);
|
||||||
|
Assert.IsNotNull(curve);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: baeea9019e894fb09d9b25f015856348
|
||||||
|
timeCreated: 1673016399
|
Loading…
Reference in New Issue
Block a user