From 1cce15590c716f32a1d887c5a773798572cac814 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:53:00 -0700 Subject: [PATCH 1/6] chore(deps): bump http-proxy-middleware from 2.0.6 to 2.0.7 in /docs~ (#1319) Bumps [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) from 2.0.6 to 2.0.7. - [Release notes](https://github.com/chimurai/http-proxy-middleware/releases) - [Changelog](https://github.com/chimurai/http-proxy-middleware/blob/v2.0.7/CHANGELOG.md) - [Commits](https://github.com/chimurai/http-proxy-middleware/compare/v2.0.6...v2.0.7) --- updated-dependencies: - dependency-name: http-proxy-middleware dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs~/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs~/yarn.lock b/docs~/yarn.lock index a5981967..e6d73456 100644 --- a/docs~/yarn.lock +++ b/docs~/yarn.lock @@ -6378,8 +6378,8 @@ __metadata: linkType: hard "http-proxy-middleware@npm:^2.0.3": - version: 2.0.6 - resolution: "http-proxy-middleware@npm:2.0.6" + version: 2.0.7 + resolution: "http-proxy-middleware@npm:2.0.7" dependencies: "@types/http-proxy": ^1.17.8 http-proxy: ^1.18.1 @@ -6391,7 +6391,7 @@ __metadata: peerDependenciesMeta: "@types/express": optional: true - checksum: 2ee85bc878afa6cbf34491e972ece0f5be0a3e5c98a60850cf40d2a9a5356e1fc57aab6cff33c1fc37691b0121c3a42602d2b1956c52577e87a5b77b62ae1c3a + checksum: 18caa21145917aa1054740353916e8f03f5a3a93bede9106f1f44d84f7b174df17af1c72bf5fade5cc440c2058ee813f47cbb2bdd6ae6874af1cf33e0ac575f3 languageName: node linkType: hard From 131f54a713d78a79e05205cef15f9b722364a080 Mon Sep 17 00:00:00 2001 From: bd_ Date: Fri, 25 Oct 2024 19:53:09 -0700 Subject: [PATCH 2/6] docs: Update JP version of mesh-settings.md (#1315) Closes: #1314 --- .../current/reference/mesh-settings.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs~/i18n/ja/docusaurus-plugin-content-docs/current/reference/mesh-settings.md b/docs~/i18n/ja/docusaurus-plugin-content-docs/current/reference/mesh-settings.md index 12459d0f..6d828753 100644 --- a/docs~/i18n/ja/docusaurus-plugin-content-docs/current/reference/mesh-settings.md +++ b/docs~/i18n/ja/docusaurus-plugin-content-docs/current/reference/mesh-settings.md @@ -28,10 +28,10 @@ Mesh Settingsコンポーネントを使用すると、特定のゲームオブ - 継承:このコンポーネントはこの設定に対して何もしません。親のMesh Settingsで設定された値を継承します。 - 設定:このコンポーネントは、そのゲームオブジェクトとその子にあるメッシュの対応する設定を設定します。 - 設定しない:このコンポーネントは、親のMesh Settingsの影響を受けないようにします。メッシュはデフォルトの設定のままです。 -- 親が継承された時は継承、または設定:親のMesh Settingsが設定モードにある場合、それが使用されます。親のMesh +- 親が継承された時は継承、それ以外では設定:親のMesh Settingsが設定モードにある場合、それが使用されます。親のMesh Settingsが適用されない場合、 このコンポーネントの設定が使用されます。衣装プレハブなどに、アバター全体の設定が優先されるようにするために便利です。 バウンズを設定する場合、バウンディングボックスは「Root Bone」として指定したトランスフォームに対して相対的に決定されます。 また、バウンズはSkinned Mesh Rendererのみに影響しますが、Anchor OverrideはMesh RendererやLine Rendererなどの他のタイプの -Rendererにも設定されます。 \ No newline at end of file +Rendererにも設定されます。 From 07b648dcc1256ed490356e2e4cebe976555f98ba Mon Sep 17 00:00:00 2001 From: "Jeremy Lam aka. Vistanz" Date: Sat, 26 Oct 2024 11:11:23 +0800 Subject: [PATCH 3/6] Fixes error when merging same parameter with different type in RC menu item (#1313) --- .../ReactiveObjects/ParameterAssignerPass.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Editor/ReactiveObjects/ParameterAssignerPass.cs b/Editor/ReactiveObjects/ParameterAssignerPass.cs index b7afd0bf..5d85b67e 100644 --- a/Editor/ReactiveObjects/ParameterAssignerPass.cs +++ b/Editor/ReactiveObjects/ParameterAssignerPass.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using nadena.dev.ndmf; using UnityEngine; +using UnityEditor.Animations; +using VRC.SDK3.Avatars.Components; using VRC.SDK3.Avatars.ScriptableObjects; namespace nadena.dev.modular_avatar.core.editor @@ -186,6 +188,22 @@ namespace nadena.dev.modular_avatar.core.editor expParams.parameters = expParams.parameters.Concat(newParameters.Values).ToArray(); } + + if (_mamiByParam.Count > 0) + { + // This make sures the parameters are correctly merged into the FX layer. + var mergeAnimator = context.AvatarRootObject.AddComponent(); + mergeAnimator.layerType = VRCAvatarDescriptor.AnimLayerType.FX; + mergeAnimator.deleteAttachedAnimator = false; + mergeAnimator.animator = new AnimatorController + { + parameters = _mamiByParam.Keys.Select(name => new AnimatorControllerParameter + { + name = name, + type = AnimatorControllerParameterType.Float, + }).ToArray(), + }; + } } internal static ControlCondition AssignMenuItemParameter( From efa263b551166bb3d58ccff489caace4755e61ca Mon Sep 17 00:00:00 2001 From: kaikoga Date: Mon, 28 Oct 2024 02:06:35 +0900 Subject: [PATCH 4/6] chore: Fix non-VRChat support (for MA 1.10.5) (#1324) * feat: add version defines for VRCSDK * chore: early return if VRCSDK project but not VRChat avatar --- Editor/Animation/AnimationDatabase.cs | 1 + Editor/Animation/AnimationServicesContext.cs | 2 ++ Editor/Animation/AnimationUtil.cs | 2 ++ Editor/Animation/PathMappings.cs | 27 ++++++++++--------- .../FixupPasses/FixupExpressionsMenuPass.cs | 2 ++ Editor/MergeAnimatorProcessor.cs | 1 + .../OptimizationPasses/PruneParametersPass.cs | 2 ++ .../AnimationGeneration/ReactiveObjectPass.cs | 2 ++ Editor/RenameParametersHook.cs | 2 ++ .../AnimParameterPathRewritingTest.cs | 8 ++++-- .../Animation/AvatarMask/AvatarMaskTest.cs | 8 ++++-- .../BaseLayerReferenceCorrectionTest.cs | 8 ++++-- .../Animation/PlayAudio/PlayAudioRemapping.cs | 6 +++-- .../MergeAnimatorTests/MergeSingleTests.cs | 8 ++++-- .../PreexistingParamsTest.cs | 3 +++ .../ProxyAnim/ProxyAnimTest.cs | 8 ++++-- .../SyncedLayerOverrideInSubStateMachine.cs | 8 ++++-- .../TypeAdjustment/ConvertTransitionTypes.cs | 3 +++ .../MergeDBT/MergeDirectBlendTreeTests.cs | 4 +++ .../ReactiveComponent/BlendshapeSyncTest.cs | 8 ++++-- .../ReactiveComponent/ObjectToggleTests.cs | 8 ++++-- .../AutoValueAssignmentTests.cs | 8 ++++-- .../ParameterAssignment/ParameterTypeTests.cs | 8 ++++-- .../ShapeDeletionAnalysis.cs | 4 +++ .../InitialStates/SCDefaultAnimation.cs | 8 ++++-- .../VisibleHeadAccessoryTest.cs | 8 ++++-- 26 files changed, 119 insertions(+), 38 deletions(-) diff --git a/Editor/Animation/AnimationDatabase.cs b/Editor/Animation/AnimationDatabase.cs index dd594092..cb8a1a8d 100644 --- a/Editor/Animation/AnimationDatabase.cs +++ b/Editor/Animation/AnimationDatabase.cs @@ -158,6 +158,7 @@ namespace nadena.dev.modular_avatar.animation #if MA_VRCSDK3_AVATARS var avatarDescriptor = context.AvatarDescriptor; + if (!avatarDescriptor) return; foreach (var layer in avatarDescriptor.baseAnimationLayers) { diff --git a/Editor/Animation/AnimationServicesContext.cs b/Editor/Animation/AnimationServicesContext.cs index bc63cec9..57ad5dd0 100644 --- a/Editor/Animation/AnimationServicesContext.cs +++ b/Editor/Animation/AnimationServicesContext.cs @@ -92,6 +92,8 @@ namespace nadena.dev.modular_avatar.animation public void AddPropertyDefinition(AnimatorControllerParameter paramDef) { #if MA_VRCSDK3_AVATARS + if (!_context.AvatarDescriptor) return; + var fx = (AnimatorController) _context.AvatarDescriptor.baseAnimationLayers .First(l => l.type == VRCAvatarDescriptor.AnimLayerType.FX) diff --git a/Editor/Animation/AnimationUtil.cs b/Editor/Animation/AnimationUtil.cs index aa026548..1016cba9 100644 --- a/Editor/Animation/AnimationUtil.cs +++ b/Editor/Animation/AnimationUtil.cs @@ -53,6 +53,8 @@ namespace nadena.dev.modular_avatar.animation // This helps reduce the risk that we'll accidentally modify the original assets. #if MA_VRCSDK3_AVATARS + if (!context.AvatarDescriptor) return; + context.AvatarDescriptor.baseAnimationLayers = CloneLayers(context, context.AvatarDescriptor.baseAnimationLayers); context.AvatarDescriptor.specialAnimationLayers = diff --git a/Editor/Animation/PathMappings.cs b/Editor/Animation/PathMappings.cs index 8ea314bc..4d53f6a2 100644 --- a/Editor/Animation/PathMappings.cs +++ b/Editor/Animation/PathMappings.cs @@ -369,21 +369,24 @@ namespace nadena.dev.modular_avatar.animation Profiler.EndSample(); #if MA_VRCSDK3_AVATARS - var layers = context.AvatarDescriptor.baseAnimationLayers - .Concat(context.AvatarDescriptor.specialAnimationLayers); - - Profiler.BeginSample("ApplyMappingsToAvatarMasks"); - foreach (var layer in layers) + if (context.AvatarDescriptor) { - ApplyMappingsToAvatarMask(layer.mask); + var layers = context.AvatarDescriptor.baseAnimationLayers + .Concat(context.AvatarDescriptor.specialAnimationLayers); - if (layer.animatorController is AnimatorController ac) - // By this point, all AnimationOverrideControllers have been collapsed into an ephemeral - // AnimatorController so we can safely modify the controller in-place. - foreach (var acLayer in ac.layers) - ApplyMappingsToAvatarMask(acLayer.avatarMask); + Profiler.BeginSample("ApplyMappingsToAvatarMasks"); + foreach (var layer in layers) + { + ApplyMappingsToAvatarMask(layer.mask); + + if (layer.animatorController is AnimatorController ac) + // By this point, all AnimationOverrideControllers have been collapsed into an ephemeral + // AnimatorController so we can safely modify the controller in-place. + foreach (var acLayer in ac.layers) + ApplyMappingsToAvatarMask(acLayer.avatarMask); + } + Profiler.EndSample(); } - Profiler.EndSample(); #endif Profiler.EndSample(); diff --git a/Editor/FixupPasses/FixupExpressionsMenuPass.cs b/Editor/FixupPasses/FixupExpressionsMenuPass.cs index f4b549ee..4f36ec2b 100644 --- a/Editor/FixupPasses/FixupExpressionsMenuPass.cs +++ b/Editor/FixupPasses/FixupExpressionsMenuPass.cs @@ -19,6 +19,8 @@ namespace nadena.dev.modular_avatar.core.editor internal static void FixupExpressionsMenu(BuildContext context) { + if (!context.AvatarDescriptor) return; + context.AvatarDescriptor.customExpressions = true; var expressionsMenu = context.AvatarDescriptor.expressionsMenu; diff --git a/Editor/MergeAnimatorProcessor.cs b/Editor/MergeAnimatorProcessor.cs index b0af81ac..aa4dbcbc 100644 --- a/Editor/MergeAnimatorProcessor.cs +++ b/Editor/MergeAnimatorProcessor.cs @@ -65,6 +65,7 @@ namespace nadena.dev.modular_avatar.core.editor mergeSessions.Clear(); var descriptor = avatarGameObject.GetComponent(); + if (!descriptor) return; if (descriptor.baseAnimationLayers != null) InitSessions(descriptor.baseAnimationLayers); if (descriptor.specialAnimationLayers != null) InitSessions(descriptor.specialAnimationLayers); diff --git a/Editor/OptimizationPasses/PruneParametersPass.cs b/Editor/OptimizationPasses/PruneParametersPass.cs index a38b3655..801fb3e9 100644 --- a/Editor/OptimizationPasses/PruneParametersPass.cs +++ b/Editor/OptimizationPasses/PruneParametersPass.cs @@ -9,6 +9,8 @@ namespace nadena.dev.modular_avatar.core.editor { protected override void Execute(ndmf.BuildContext context) { + if (!context.AvatarDescriptor) return; + var expParams = context.AvatarDescriptor.expressionParameters; if (expParams != null && context.IsTemporaryAsset(expParams)) { diff --git a/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectPass.cs b/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectPass.cs index ae77c80f..2d73a816 100644 --- a/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectPass.cs +++ b/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectPass.cs @@ -34,6 +34,8 @@ namespace nadena.dev.modular_avatar.core.editor internal void Execute() { + if (!context.AvatarDescriptor) return; + // Having a WD OFF layer after WD ON layers can break WD. We match the behavior of the existing states, // and if mixed, use WD ON to maximize compatibility. _writeDefaults = MergeAnimatorProcessor.ProbeWriteDefaults(FindFxController().animatorController as AnimatorController) ?? true; diff --git a/Editor/RenameParametersHook.cs b/Editor/RenameParametersHook.cs index 5bd401c3..25ce41ef 100644 --- a/Editor/RenameParametersHook.cs +++ b/Editor/RenameParametersHook.cs @@ -159,6 +159,8 @@ namespace nadena.dev.modular_avatar.core.editor public void OnPreprocessAvatar(GameObject avatar, BuildContext context) { + if (!context.AvatarDescriptor) return; + _context = context; var syncParams = WalkTree(avatar); diff --git a/UnitTests~/Animation/AnimParameterPathRewrite/AnimParameterPathRewritingTest.cs b/UnitTests~/Animation/AnimParameterPathRewrite/AnimParameterPathRewritingTest.cs index cf51e6b2..426b9ad3 100644 --- a/UnitTests~/Animation/AnimParameterPathRewrite/AnimParameterPathRewritingTest.cs +++ b/UnitTests~/Animation/AnimParameterPathRewrite/AnimParameterPathRewritingTest.cs @@ -1,4 +1,6 @@ -using nadena.dev.modular_avatar.core.editor; +#if MA_VRCSDK3_AVATARS + +using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEditor; using UnityEngine; @@ -36,4 +38,6 @@ namespace modular_avatar_tests Assert.AreEqual("x", curves[0].propertyName); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/Animation/AvatarMask/AvatarMaskTest.cs b/UnitTests~/Animation/AvatarMask/AvatarMaskTest.cs index 897e323f..09bf1825 100644 --- a/UnitTests~/Animation/AvatarMask/AvatarMaskTest.cs +++ b/UnitTests~/Animation/AvatarMask/AvatarMaskTest.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Linq; using nadena.dev.ndmf; @@ -158,4 +160,6 @@ namespace modular_avatar_tests Assert.IsFalse(state.transformMaskElements.Any(e => e.Item1 == "Armature/Hips/UpperLeg.R")); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/Animation/BaseLayerReferenceCorrection/BaseLayerReferenceCorrectionTest.cs b/UnitTests~/Animation/BaseLayerReferenceCorrection/BaseLayerReferenceCorrectionTest.cs index e2bed491..2f9bb828 100644 --- a/UnitTests~/Animation/BaseLayerReferenceCorrection/BaseLayerReferenceCorrectionTest.cs +++ b/UnitTests~/Animation/BaseLayerReferenceCorrection/BaseLayerReferenceCorrectionTest.cs @@ -1,4 +1,6 @@ -using System.Linq; +#if MA_VRCSDK3_AVATARS + +using System.Linq; using nadena.dev.ndmf; using NUnit.Framework; using UnityEditor.Animations; @@ -26,4 +28,6 @@ namespace modular_avatar_tests Assert.AreEqual(desiredIndex, alc.layer); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/Animation/PlayAudio/PlayAudioRemapping.cs b/UnitTests~/Animation/PlayAudio/PlayAudioRemapping.cs index 9ccdc7e3..8bdf1489 100644 --- a/UnitTests~/Animation/PlayAudio/PlayAudioRemapping.cs +++ b/UnitTests~/Animation/PlayAudio/PlayAudioRemapping.cs @@ -1,9 +1,10 @@ -using nadena.dev.modular_avatar.core.editor; +#if MA_VRCSDK3_AVATARS_3_5_2_OR_NEWER + +using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEditor.Animations; using VRC.SDK3.Avatars.Components; -#if MA_VRCSDK3_AVATARS_3_5_2_OR_NEWER namespace modular_avatar_tests { public class PlayAudioRemapping : TestBase @@ -28,4 +29,5 @@ namespace modular_avatar_tests } } } + #endif \ No newline at end of file diff --git a/UnitTests~/MergeAnimatorTests/MergeSingleTests.cs b/UnitTests~/MergeAnimatorTests/MergeSingleTests.cs index 1f546212..2da5afbf 100644 --- a/UnitTests~/MergeAnimatorTests/MergeSingleTests.cs +++ b/UnitTests~/MergeAnimatorTests/MergeSingleTests.cs @@ -1,4 +1,6 @@ -using modular_avatar_tests; +#if MA_VRCSDK3_AVATARS + +using modular_avatar_tests; using nadena.dev.modular_avatar.animation; using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core.editor; @@ -47,4 +49,6 @@ namespace UnitTests.MergeAnimatorTests Assert.IsTrue(state.motion.name.StartsWith("Anim2")); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/MergeAnimatorTests/PreexistingAnimatorParams/PreexistingParamsTest.cs b/UnitTests~/MergeAnimatorTests/PreexistingAnimatorParams/PreexistingParamsTest.cs index 8af5146e..3f1739d7 100644 --- a/UnitTests~/MergeAnimatorTests/PreexistingAnimatorParams/PreexistingParamsTest.cs +++ b/UnitTests~/MergeAnimatorTests/PreexistingAnimatorParams/PreexistingParamsTest.cs @@ -1,3 +1,5 @@ +#if MA_VRCSDK3_AVATARS + using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -35,3 +37,4 @@ public class PreexistingParamsTest : TestBase } } +#endif \ No newline at end of file diff --git a/UnitTests~/MergeAnimatorTests/ProxyAnim/ProxyAnimTest.cs b/UnitTests~/MergeAnimatorTests/ProxyAnim/ProxyAnimTest.cs index b67e30d1..974865d7 100644 --- a/UnitTests~/MergeAnimatorTests/ProxyAnim/ProxyAnimTest.cs +++ b/UnitTests~/MergeAnimatorTests/ProxyAnim/ProxyAnimTest.cs @@ -1,4 +1,6 @@ -using modular_avatar_tests; +#if MA_VRCSDK3_AVATARS + +using modular_avatar_tests; using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; @@ -25,4 +27,6 @@ namespace UnitTests.MergeAnimatorTests.ProxyAnim Assert.AreEqual(originalClip, resultClip); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/MergeAnimatorTests/SyncedLayerOverrideInSubStatemachine/SyncedLayerOverrideInSubStateMachine.cs b/UnitTests~/MergeAnimatorTests/SyncedLayerOverrideInSubStatemachine/SyncedLayerOverrideInSubStateMachine.cs index 765e1333..ecf3c88a 100644 --- a/UnitTests~/MergeAnimatorTests/SyncedLayerOverrideInSubStatemachine/SyncedLayerOverrideInSubStateMachine.cs +++ b/UnitTests~/MergeAnimatorTests/SyncedLayerOverrideInSubStatemachine/SyncedLayerOverrideInSubStateMachine.cs @@ -1,4 +1,6 @@ -using modular_avatar_tests; +#if MA_VRCSDK3_AVATARS + +using modular_avatar_tests; using nadena.dev.ndmf; using NUnit.Framework; using UnityEditor.Animations; @@ -38,4 +40,6 @@ namespace UnitTests.MergeAnimatorTests.SyncedLayerOverrideInSubStatemachine Assert.NotNull(motion); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/MergeAnimatorTests/TypeAdjustment/ConvertTransitionTypes.cs b/UnitTests~/MergeAnimatorTests/TypeAdjustment/ConvertTransitionTypes.cs index 0161235d..e0a024de 100644 --- a/UnitTests~/MergeAnimatorTests/TypeAdjustment/ConvertTransitionTypes.cs +++ b/UnitTests~/MergeAnimatorTests/TypeAdjustment/ConvertTransitionTypes.cs @@ -1,3 +1,5 @@ +#if MA_VRCSDK3_AVATARS + using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -268,3 +270,4 @@ public class ConvertTransitionTypes : TestBase } } +#endif \ No newline at end of file diff --git a/UnitTests~/MergeDBT/MergeDirectBlendTreeTests.cs b/UnitTests~/MergeDBT/MergeDirectBlendTreeTests.cs index 188ef484..61c00154 100644 --- a/UnitTests~/MergeDBT/MergeDirectBlendTreeTests.cs +++ b/UnitTests~/MergeDBT/MergeDirectBlendTreeTests.cs @@ -1,3 +1,5 @@ +#if MA_VRCSDK3_AVATARS + using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; @@ -24,3 +26,5 @@ public class MergeDirectBlendTreeTests : TestBase Assert.AreEqual(0, parameters["DEF"]); } } + +#endif \ No newline at end of file diff --git a/UnitTests~/ReactiveComponent/BlendshapeSyncTest.cs b/UnitTests~/ReactiveComponent/BlendshapeSyncTest.cs index 19d61e6c..eb8bba90 100644 --- a/UnitTests~/ReactiveComponent/BlendshapeSyncTest.cs +++ b/UnitTests~/ReactiveComponent/BlendshapeSyncTest.cs @@ -1,4 +1,6 @@ -using System.Linq; +#if MA_VRCSDK3_AVATARS + +using System.Linq; using modular_avatar_tests; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; @@ -58,4 +60,6 @@ namespace UnitTests.ReactiveComponent Assert.AreEqual(m3.actionGroups, m1.actionGroups); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/ReactiveComponent/ObjectToggleTests.cs b/UnitTests~/ReactiveComponent/ObjectToggleTests.cs index 6637ff05..30bbfe65 100644 --- a/UnitTests~/ReactiveComponent/ObjectToggleTests.cs +++ b/UnitTests~/ReactiveComponent/ObjectToggleTests.cs @@ -1,4 +1,6 @@ -using System.Linq; +#if MA_VRCSDK3_AVATARS + +using System.Linq; using modular_avatar_tests; using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core.editor; @@ -47,4 +49,6 @@ namespace UnitTests.ReactiveComponent Assert.IsFalse(obj.activeSelf); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/ReactiveComponent/ParameterAssignment/AutoValueAssignmentTests.cs b/UnitTests~/ReactiveComponent/ParameterAssignment/AutoValueAssignmentTests.cs index d7eb71f5..a2c9b5b8 100644 --- a/UnitTests~/ReactiveComponent/ParameterAssignment/AutoValueAssignmentTests.cs +++ b/UnitTests~/ReactiveComponent/ParameterAssignment/AutoValueAssignmentTests.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Linq; using modular_avatar_tests; @@ -112,4 +114,6 @@ namespace UnitTests.ReactiveComponent.ParameterAssignment Assert.AreEqual(expectedDefaultValue, avDesc.expressionParameters.parameters.Single().defaultValue); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/ReactiveComponent/ParameterAssignment/ParameterTypeTests.cs b/UnitTests~/ReactiveComponent/ParameterAssignment/ParameterTypeTests.cs index 6a4a45b5..f16844c3 100644 --- a/UnitTests~/ReactiveComponent/ParameterAssignment/ParameterTypeTests.cs +++ b/UnitTests~/ReactiveComponent/ParameterAssignment/ParameterTypeTests.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Linq; using modular_avatar_tests; using nadena.dev.modular_avatar.core; @@ -82,4 +84,6 @@ namespace UnitTests.ReactiveComponent.ParameterAssignment Assert.AreEqual(expected, descriptor.expressionParameters.parameters.Single().valueType); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/ReactiveComponent/ShapeDeletionAnalysis.cs b/UnitTests~/ReactiveComponent/ShapeDeletionAnalysis.cs index 7cb78e50..debfe8c9 100644 --- a/UnitTests~/ReactiveComponent/ShapeDeletionAnalysis.cs +++ b/UnitTests~/ReactiveComponent/ShapeDeletionAnalysis.cs @@ -1,3 +1,5 @@ +#if MA_VRCSDK3_AVATARS + using System.Collections; using System.Collections.Generic; using System.Linq; @@ -96,3 +98,5 @@ public class ShapeDeletionAnalysis : TestBase Assert.AreEqual(originalSharedMesh, mesh.sharedMesh); } } + +#endif \ No newline at end of file diff --git a/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.cs b/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.cs index c1061b3e..2651f178 100644 --- a/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.cs +++ b/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.cs @@ -1,4 +1,6 @@ -using modular_avatar_tests; +#if MA_VRCSDK3_AVATARS + +using modular_avatar_tests; using nadena.dev.modular_avatar.animation; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; @@ -121,4 +123,6 @@ namespace ShapeChangerTests Assert.AreEqual(100.0f, smr.GetBlendShapeWeight(sharedMesh.GetBlendShapeIndex("key3")), 0.1f); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/VisibleHeadAccessoryTest/VisibleHeadAccessoryTest.cs b/UnitTests~/VisibleHeadAccessoryTest/VisibleHeadAccessoryTest.cs index a85f2954..7685066b 100644 --- a/UnitTests~/VisibleHeadAccessoryTest/VisibleHeadAccessoryTest.cs +++ b/UnitTests~/VisibleHeadAccessoryTest/VisibleHeadAccessoryTest.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +#if MA_VRCSDK3_AVATARS + +using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -57,4 +59,6 @@ namespace UnitTests.VisibleHeadAccessoryTest Assert.AreEqual(headchop.globalScaleFactor, 1); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file From 1153abd16eea72eaf60df029e200a379e68a6fb1 Mon Sep 17 00:00:00 2001 From: bd_ Date: Sun, 27 Oct 2024 10:07:14 -0700 Subject: [PATCH 5/6] fix: NRE when Move Independently is placed on a scene root (#1321) Closes: #1317 --- Runtime/MAMoveIndependently.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Runtime/MAMoveIndependently.cs b/Runtime/MAMoveIndependently.cs index b193e4a2..fc128baa 100644 --- a/Runtime/MAMoveIndependently.cs +++ b/Runtime/MAMoveIndependently.cs @@ -218,6 +218,8 @@ namespace nadena.dev.modular_avatar.core.ArmatureAwase return; } + if (transform.parent == null) return; + var pos = transform.localPosition; var rot = transform.localRotation; var scale = transform.localScale; From 32ea6678f72515cce69c5817ef87133553894077 Mon Sep 17 00:00:00 2001 From: bd_ Date: Sun, 27 Oct 2024 10:07:23 -0700 Subject: [PATCH 6/6] feat: object references are now corrected when their target path is renamed/changes (#1323) --- Editor/ObjectReferenceFixer.cs | 53 +++++++++++++++++++++++++++----- Runtime/AvatarObjectReference.cs | 5 +++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Editor/ObjectReferenceFixer.cs b/Editor/ObjectReferenceFixer.cs index b6fe69e6..b1c6108d 100644 --- a/Editor/ObjectReferenceFixer.cs +++ b/Editor/ObjectReferenceFixer.cs @@ -11,30 +11,51 @@ namespace nadena.dev.modular_avatar.core { private static ComputeContext _context; - private static PrefabStage _lastStage; + private static int? _lastStage; + private static int? GetCurrentContentsRootId(out GameObject contentsRoot) + { + contentsRoot = null; + + var stage = PrefabStageUtility.GetCurrentPrefabStage(); + if (stage == null || stage.prefabContentsRoot == null) return null; + + contentsRoot = stage.prefabContentsRoot; + + return stage.prefabContentsRoot.GetInstanceID(); + } + [InitializeOnLoadMethod] private static void Init() { EditorApplication.delayCall += ProcessObjectReferences; EditorApplication.update += () => { - if (PrefabStageUtility.GetCurrentPrefabStage() != _lastStage) _context?.Invalidate?.Invoke(); + var curStage = GetCurrentContentsRootId(out _); + + Debug.Log($"{_lastStage} => {curStage}"); + + if (curStage != _lastStage) + { + _context?.Invalidate?.Invoke(); + } }; } private static void ProcessObjectReferences() { - _lastStage = PrefabStageUtility.GetCurrentPrefabStage(); + _lastStage = GetCurrentContentsRootId(out var contentsRoot); + + AvatarObjectReference.InvalidateAll(); _context = new ComputeContext("ObjectReferenceFixer"); _context.InvokeOnInvalidate(typeof(ObjectReferenceFixer), _ => ProcessObjectReferences()); IEnumerable withReferences = _context.GetComponentsByType(); - if (_lastStage != null) + if (contentsRoot != null) withReferences = withReferences.Concat( - _context.GetComponentsInChildren(_lastStage.prefabContentsRoot, true) + _context.GetComponentsInChildren(contentsRoot, true) ); foreach (var obj in withReferences) @@ -56,10 +77,26 @@ namespace nadena.dev.modular_avatar.core foreach (var (targetObject, referencePath, objRef) in references) { - if (targetObject == null) continue; - _context.ObservePath(targetObject.transform); + var resolvedTarget = objRef.Get(component); + if (objRef.Get(component) == null) continue; + if (targetObject == null) + { + Undo.RecordObject(component, ""); + objRef.targetObject = resolvedTarget; + dirty = true; + } + else + { + // Direct object reference always wins in the event of a conflict. + resolvedTarget = targetObject; + } - if (!targetObject.transform.IsChildOf(avatar.transform)) continue; + foreach (var t in _context.ObservePath(resolvedTarget.transform)) + { + _context.Observe(t.gameObject, g => g.name); + } + + if (!resolvedTarget.transform.IsChildOf(avatar.transform)) continue; if (objRef.IsConsistent(avatar)) continue; diff --git a/Runtime/AvatarObjectReference.cs b/Runtime/AvatarObjectReference.cs index bc6407a0..db3c88df 100644 --- a/Runtime/AvatarObjectReference.cs +++ b/Runtime/AvatarObjectReference.cs @@ -29,6 +29,11 @@ namespace nadena.dev.modular_avatar.core EditorApplication.hierarchyChanged += () => HIERARCHY_CHANGED_SEQ += 1; } #endif + + internal static void InvalidateAll() + { + HIERARCHY_CHANGED_SEQ++; + } public AvatarObjectReference Clone() {