fix: match WD = off setting is not respected (#1528)

Closes: #1519
This commit is contained in:
bd_ 2025-03-23 11:34:19 -07:00 committed by GitHub
parent 8a45515af0
commit e46e958f39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 34 additions and 12 deletions

View File

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- [#1522] `Convert Constraints` がアニメーション参照を変換できない問題を修正
- [#1528] `Merge Animator``アバターのWrite Defaults設定に合わせる` 設定を無視し、常に合わせてしまう問題を修正
### Changed

View File

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- [#1522] `Convert Constraints` failed to convert animation references
- [#1528] `Merge Animator` ignored the `Match Avatar Write Defaults` setting and always matched
### Changed

View File

@ -137,6 +137,11 @@ namespace nadena.dev.modular_avatar.core.editor
return;
}
if (!merge.matchAvatarWriteDefaults)
{
initialWriteDefaults = null;
}
var vac = context.PluginBuildContext.Extension<VirtualControllerContext>();
if (!vac.Controllers.TryGetValue(merge, out var clonedController)) return;

View File

@ -272,7 +272,7 @@ AnimatorController:
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
- serializedVersion: 5
m_Name: 1_Additive
m_Name: X_Additive
m_StateMachine: {fileID: 2859792172588103306}
m_Mask: {fileID: 0}
m_Motions: []
@ -284,7 +284,7 @@ AnimatorController:
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
- serializedVersion: 5
m_Name: 1_SingleMotion
m_Name: X_SingleMotion
m_StateMachine: {fileID: 7425114331284477142}
m_Mask: {fileID: 0}
m_Motions: []
@ -360,7 +360,7 @@ AnimatorStateMachine:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 1_Additive
m_Name: X_Additive
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -3889880041459077057}
@ -459,7 +459,7 @@ AnimatorStateMachine:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 1_SingleMotion
m_Name: X_SingleMotion
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -2269384398499780410}

View File

@ -13,24 +13,33 @@ namespace UnitTests.MergeAnimatorTests.WriteDefaults
[Test]
public void TestWriteDefaultsMerge(
[Values("WD_OFF", "WD_ON", "Ambiguous")] string scenario,
[Values(true, false)] bool mergeSetMode
[Values(true, false)] bool mergeAnimatorInitialState,
[Values(true, false)] bool matchWD
)
{
bool? wdMode;
bool? baseFxWdState;
switch (scenario)
{
case "WD_OFF": wdMode = false; break;
case "WD_ON": wdMode = true; break;
default: wdMode = null; break;
case "WD_OFF": baseFxWdState = false; break;
case "WD_ON": baseFxWdState = true; break;
default: baseFxWdState = null; break;
}
// If the base layer is ambiguous and WD is disabled, the only thing we can assert is that nothing changed.
// This is kind of a pain, so... TODO
if (baseFxWdState == null && !matchWD) return;
var root = CreateRoot(scenario);
var m1 = CreateChild(root, "m1").AddComponent<ModularAvatarMergeAnimator>();
var m2 = CreateChild(root, "m2").AddComponent<ModularAvatarMergeAnimator>();
// m1 provides the base FX layer for the avatar
m1.animator = LoadAsset<AnimatorController>(scenario + ".controller");
m1.mergeAnimatorMode = MergeAnimatorMode.Replace;
m2.animator = LoadAsset<AnimatorController>("TestSet_" + mergeSetMode + ".controller");
m2.animator = LoadAsset<AnimatorController>("TestSet_" + mergeAnimatorInitialState + ".controller");
m2.mergeAnimatorMode = MergeAnimatorMode.Append;
m2.matchAvatarWriteDefaults = matchWD;
AvatarProcessor.ProcessAvatar(root);
@ -46,8 +55,14 @@ namespace UnitTests.MergeAnimatorTests.WriteDefaults
switch (layer.Name[0])
{
case 'M': expectedState = wdMode ?? mergeSetMode; break;
case 'X': expectedState = mergeSetMode; break;
// M layers: We expect to "M"atch WD state if the merge component is set to match WD (and a WD mode
// was determined); otherwise, it should keep its original state.
case 'M':
{
expectedState = (matchWD ? baseFxWdState : null) ?? mergeAnimatorInitialState;
break;
}
case 'X': expectedState = mergeAnimatorInitialState; break;
default: continue;
}