From 94e33e1ab2c13ac85aa9f16194bb4c3b73e72f4e Mon Sep 17 00:00:00 2001 From: bd_ Date: Sat, 29 Mar 2025 16:40:54 -0700 Subject: [PATCH] feat: use stable identifiers for MA Menu Items --- CHANGELOG-PRERELEASE-jp.md | 1 + CHANGELOG-PRERELEASE.md | 1 + CHANGELOG-jp.md | 4 ++-- CHANGELOG.md | 4 ++-- Editor/ReactiveObjects/ParameterAssignerPass.cs | 4 +++- Editor/RenameParametersHook.cs | 12 +++++------- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG-PRERELEASE-jp.md b/CHANGELOG-PRERELEASE-jp.md index 040d37a1..5f348413 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 ### Changed +- [#1530] `MA Menu Item`の自動パラメーター機能も、オブジェクトのパスに基づいて名前を割り当てるようになりました。 ### Removed diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index 10d91175..c215cd47 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 ### Changed +- [#1530] `MA Menu Item` auto parameters now also assign names based on object paths ### Removed diff --git a/CHANGELOG-jp.md b/CHANGELOG-jp.md index b79c76b1..a1d98f3a 100644 --- a/CHANGELOG-jp.md +++ b/CHANGELOG-jp.md @@ -27,8 +27,8 @@ Modular Avatarの主な変更点をこのファイルで記録しています。 - [#1513] iOSビルドでエクスプレッションメニューアイコンの圧縮処理が壊れる問題を修正 ### Changed -- [#1529] `MA Parameters` の自動リネームは、オブジェクトのパスに基づいて新しい名前を割り当てるように変更されました。これにより、 - `MA Sync Parameter Sequence` との互換性が向上します。 +- [#1529] `MA Parameters` の自動リネームと `MA Menu Item` の自動パラメーター機能は、オブジェクトのパスに基づいて名前 + を割り当てるように変更されました。 - `MA Sync Parameter Sequence` を使用している場合は、このバージョンに更新した後、SyncedParamsアセットを空にして、 すべてのプラットフォームを再アップロードすることをお勧めします。 - [#1514] `Merge Blend Tree` は `Merge Motion (Blend Tree)` に改名され、アニメーションクリップにも対応するようになりました diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ce26219..ef1b6388 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,8 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#1513] Expression menu icon compression broke on iOS builds ### Changed -- [#1529] `MA Parameters` auto-rename now assigns new names based on the path of the object. This should improve - compatibility with `MA Sync Parameter Sequence` +- [#1529] `MA Parameters` auto-rename and `MA Menu Item`'s automatic parameter feature now assign names based on the + path of the object. This should improve compatibility with `MA Sync Parameter Sequence` - If you are using `MA Sync Parameter Sequence`, it's a good idea to empty your SyncedParams asset and reupload all platforms after updating to this version. - [#1514] `Merge Blend Tree` is now `Merge Motion (Blend Tree)` and supports merging animation clips as well as blend trees diff --git a/Editor/ReactiveObjects/ParameterAssignerPass.cs b/Editor/ReactiveObjects/ParameterAssignerPass.cs index fde64af2..7ec3247e 100644 --- a/Editor/ReactiveObjects/ParameterAssignerPass.cs +++ b/Editor/ReactiveObjects/ParameterAssignerPass.cs @@ -54,6 +54,7 @@ namespace nadena.dev.modular_avatar.core.editor if (!context.AvatarDescriptor) return; var paramIndex = 0; + var mappings = ParameterRenameMappings.Get(context); var declaredParams = context.AvatarDescriptor.expressionParameters.parameters .GroupBy(p => p.name).Select(l => l.First()) @@ -72,7 +73,8 @@ namespace nadena.dev.modular_avatar.core.editor if (mami.Control == null) mami.Control = new VRCExpressionsMenu.Control(); mami.Control.parameter = new VRCExpressionsMenu.Control.Parameter { - name = $"__MA/AutoParam/{mami.gameObject.name}${paramIndex++}" + name = mappings.Remap(mami, ParameterNamespace.Animator, + $"__MA/AutoParam/{mami.gameObject.name}") }; } diff --git a/Editor/RenameParametersHook.cs b/Editor/RenameParametersHook.cs index ccf160e2..31846ccd 100644 --- a/Editor/RenameParametersHook.cs +++ b/Editor/RenameParametersHook.cs @@ -19,8 +19,6 @@ using VRC.SDK3.Dynamics.Contact.Components; using VRC.SDK3.Dynamics.PhysBone.Components; using Object = UnityEngine.Object; -using UnityObject = UnityEngine.Object; - #endregion namespace nadena.dev.modular_avatar.core.editor @@ -33,11 +31,11 @@ namespace nadena.dev.modular_avatar.core.editor } private readonly HashSet usedNames = new(); - public Dictionary<(ModularAvatarParameters, ParameterNamespace, string), string> Remappings = new(); + public Dictionary<(Component, ParameterNamespace, string), string> Remappings = new(); private int internalParamIndex; - public string Remap(ModularAvatarParameters p, ParameterNamespace ns, string s) + public string Remap(Component p, ParameterNamespace ns, string s) { var tuple = (p, ns, s); @@ -96,8 +94,8 @@ namespace nadena.dev.modular_avatar.core.editor private static long encounterOrderCounter; public ParameterConfig ResolvedParameter; - public List TypeSources = new List(); - public List DefaultSources = new List(); + public List TypeSources = new List(); + public List DefaultSources = new List(); public ImmutableHashSet ConflictingValues = ImmutableHashSet.Empty; public ImmutableHashSet ConflictingSyncTypes = ImmutableHashSet.Empty; @@ -197,7 +195,7 @@ namespace nadena.dev.modular_avatar.core.editor // clean up all parameters objects before the ParameterAssignerPass runs foreach (var p in avatar.GetComponentsInChildren()) - UnityObject.DestroyImmediate(p); + Object.DestroyImmediate(p); } private void SetExpressionParameters(GameObject avatarRoot, ImmutableDictionary allParams)