diff --git a/CHANGELOG-PRERELEASE-jp.md b/CHANGELOG-PRERELEASE-jp.md index 4c9478c4..96b648cb 100644 --- a/CHANGELOG-PRERELEASE-jp.md +++ b/CHANGELOG-PRERELEASE-jp.md @@ -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 diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index 9b9c3450..3beec340 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -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 diff --git a/Editor/MergeAnimatorProcessor.cs b/Editor/MergeAnimatorProcessor.cs index b331ee59..84060558 100644 --- a/Editor/MergeAnimatorProcessor.cs +++ b/Editor/MergeAnimatorProcessor.cs @@ -137,6 +137,11 @@ namespace nadena.dev.modular_avatar.core.editor return; } + if (!merge.matchAvatarWriteDefaults) + { + initialWriteDefaults = null; + } + var vac = context.PluginBuildContext.Extension(); if (!vac.Controllers.TryGetValue(merge, out var clonedController)) return; diff --git a/UnitTests~/MergeAnimatorTests/WriteDefaults/TestSet_true.controller b/UnitTests~/MergeAnimatorTests/WriteDefaults/TestSet_true.controller index 138df46c..595ae983 100644 --- a/UnitTests~/MergeAnimatorTests/WriteDefaults/TestSet_true.controller +++ b/UnitTests~/MergeAnimatorTests/WriteDefaults/TestSet_true.controller @@ -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} diff --git a/UnitTests~/MergeAnimatorTests/WriteDefaults/WriteDefaultsMergeTests.cs b/UnitTests~/MergeAnimatorTests/WriteDefaults/WriteDefaultsMergeTests.cs index 921349b6..e67035fd 100644 --- a/UnitTests~/MergeAnimatorTests/WriteDefaults/WriteDefaultsMergeTests.cs +++ b/UnitTests~/MergeAnimatorTests/WriteDefaults/WriteDefaultsMergeTests.cs @@ -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(); var m2 = CreateChild(root, "m2").AddComponent(); + // m1 provides the base FX layer for the avatar m1.animator = LoadAsset(scenario + ".controller"); m1.mergeAnimatorMode = MergeAnimatorMode.Replace; - m2.animator = LoadAsset("TestSet_" + mergeSetMode + ".controller"); + + m2.animator = LoadAsset("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; }