mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 20:25:07 +08:00
aa698565ab
* chore: refactor state machine clone logic out as a separate class * feat: add layer priority and relative path root options to Merge Animator * feat: add Merge Blend Tree component * chore: adjust NDMF dependency * docs: update merge-animator docs * docs: merge blend tree docs
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System.Linq;
|
|
using NUnit.Framework;
|
|
using UnityEditor;
|
|
using UnityEditor.Animations;
|
|
using UnityEngine;
|
|
|
|
namespace modular_avatar_tests
|
|
{
|
|
public static class AnimationTestUtil
|
|
{
|
|
public static AnimatorController TestController(string name, Motion motion = null)
|
|
{
|
|
var controller = new AnimatorController();
|
|
var stateMachine = new AnimatorStateMachine();
|
|
var state = new AnimatorState();
|
|
state.name = name;
|
|
|
|
controller.layers = new[]
|
|
{
|
|
new AnimatorControllerLayer
|
|
{
|
|
blendingMode = AnimatorLayerBlendingMode.Override,
|
|
defaultWeight = 1,
|
|
name = name,
|
|
stateMachine = stateMachine
|
|
}
|
|
};
|
|
|
|
stateMachine.name = name;
|
|
stateMachine.states = new[]
|
|
{
|
|
new ChildAnimatorState()
|
|
{
|
|
state = state
|
|
}
|
|
};
|
|
stateMachine.defaultState = state;
|
|
state.motion = motion;
|
|
|
|
return controller;
|
|
}
|
|
|
|
public static AnimationClip AnimationWithPath(string path)
|
|
{
|
|
AnimationClip clip = new AnimationClip();
|
|
clip.SetCurve(path, typeof(Transform), "localPosition.x", AnimationCurve.Constant(0, 1, 0));
|
|
return clip;
|
|
}
|
|
|
|
public static void AssertAnimationHasPath(AnimationClip clip, string path)
|
|
{
|
|
Assert.IsTrue(AnimationUtility.GetCurveBindings(clip).Any(b => b.path == path));
|
|
}
|
|
}
|
|
} |