mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
chore: Add AnimateAddedBones test
This commit is contained in:
parent
85676c5fbf
commit
f64f00e2d3
@ -7,7 +7,7 @@ AnimatorStateMachine:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Base Layer
|
||||
m_Name: merged
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 2149298753904408782}
|
||||
@ -33,7 +33,7 @@ AnimatorController:
|
||||
m_AnimatorParameters: []
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
m_Name: merged
|
||||
m_StateMachine: {fileID: -9015797059024545987}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
@ -0,0 +1,48 @@
|
||||
using System.Linq;
|
||||
using nadena.dev.modular_avatar.core.editor;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
|
||||
namespace modular_avatar_tests.AnimateAddedBones
|
||||
{
|
||||
/// <summary>
|
||||
/// This test verifies that merged animations which affect a bone newly added to an armature by Merge Armature
|
||||
/// are properly adjusted for the new bone path.
|
||||
/// </summary>
|
||||
public class AnimateAddedBones : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void AnimatesAddedBones()
|
||||
{
|
||||
var prefab = CreatePrefab("AnimateAddedBones.prefab");
|
||||
AvatarProcessor.ProcessAvatar(prefab);
|
||||
|
||||
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 == "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;
|
||||
Assert.True(cubeObject.name.StartsWith("Cube$"));
|
||||
|
||||
var binding =
|
||||
EditorCurveBinding.FloatCurve("Armature/Hips/" + cubeObject.name, typeof(Transform),
|
||||
"localEulerAnglesRaw.x");
|
||||
Assert.NotNull(AnimationUtility.GetEditorCurve(motion, binding));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef5030710e5f4bcca49b82ef9307fb11
|
||||
timeCreated: 1673015480
|
@ -9,42 +9,8 @@ using VRC.SDK3.Avatars.Components;
|
||||
|
||||
namespace modular_avatar_tests
|
||||
{
|
||||
public class PathMappingTest
|
||||
public class PathMappingTest : TestBase
|
||||
{
|
||||
private List<GameObject> objects;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
objects = new List<GameObject>();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
Object.DestroyImmediate(obj);
|
||||
}
|
||||
}
|
||||
|
||||
GameObject CreateRoot(string name)
|
||||
{
|
||||
var go = new GameObject(name);
|
||||
objects.Add(go);
|
||||
// Needed for avatar path finding functions to work properly
|
||||
go.AddComponent(typeof(VRCAvatarDescriptor));
|
||||
return go;
|
||||
}
|
||||
|
||||
GameObject CreateChild(GameObject parent, string name)
|
||||
{
|
||||
var go = new GameObject(name);
|
||||
go.transform.parent = parent.transform;
|
||||
objects.Add(go);
|
||||
return go;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TracksSimpleRenames()
|
||||
{
|
||||
|
65
Assets/_ModularAvatar/EditModeTests/TestBase.cs
Normal file
65
Assets/_ModularAvatar/EditModeTests/TestBase.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
using nadena.dev.modular_avatar.core.editor;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
|
||||
namespace modular_avatar_tests
|
||||
{
|
||||
public class TestBase
|
||||
{
|
||||
private List<GameObject> objects;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
objects = new List<GameObject>();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
Object.DestroyImmediate(obj);
|
||||
}
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
void Cleanup()
|
||||
{
|
||||
Util.DeleteTemporaryAssets();
|
||||
}
|
||||
|
||||
protected GameObject CreateRoot(string name)
|
||||
{
|
||||
var go = new GameObject(name);
|
||||
objects.Add(go);
|
||||
// Needed for avatar path finding functions to work properly
|
||||
go.AddComponent(typeof(VRCAvatarDescriptor));
|
||||
return go;
|
||||
}
|
||||
|
||||
protected GameObject CreateChild(GameObject parent, string name)
|
||||
{
|
||||
var go = new GameObject(name);
|
||||
go.transform.parent = parent.transform;
|
||||
objects.Add(go);
|
||||
return go;
|
||||
}
|
||||
|
||||
protected GameObject CreatePrefab(string relPath)
|
||||
{
|
||||
var prefabRoot = "Assets/_ModularAvatar/EditModeTests/" + GetType().Name + "/";
|
||||
var prefabPath = prefabRoot + relPath;
|
||||
|
||||
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
|
||||
Assert.NotNull(prefab, "Missing test prefab {0}", prefabPath);
|
||||
|
||||
var go = Object.Instantiate(prefab);
|
||||
objects.Add(go);
|
||||
return go;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/_ModularAvatar/EditModeTests/TestBase.cs.meta
Normal file
3
Assets/_ModularAvatar/EditModeTests/TestBase.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3babb39034641909c515570601d049f
|
||||
timeCreated: 1673015522
|
Loading…
Reference in New Issue
Block a user