From 9e4c876305c5607aa5239eb799cb7ea178446f9b Mon Sep 17 00:00:00 2001 From: bd_ Date: Tue, 26 Dec 2023 16:10:45 +0900 Subject: [PATCH] opti: prune garbage sample expression parameters found in VRChat's template asset (#578) --- .../OptimizationPasses/PruneParametersPass.cs | 17 +++++++++++++++++ .../PruneParametersPass.cs.meta | 3 +++ Editor/PluginDefinition/PluginDefinition.cs | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Editor/OptimizationPasses/PruneParametersPass.cs create mode 100644 Editor/OptimizationPasses/PruneParametersPass.cs.meta diff --git a/Editor/OptimizationPasses/PruneParametersPass.cs b/Editor/OptimizationPasses/PruneParametersPass.cs new file mode 100644 index 00000000..97da2939 --- /dev/null +++ b/Editor/OptimizationPasses/PruneParametersPass.cs @@ -0,0 +1,17 @@ +using System.Linq; +using nadena.dev.ndmf; + +namespace nadena.dev.modular_avatar.core.editor +{ + internal class PruneParametersPass : Pass + { + protected override void Execute(ndmf.BuildContext context) + { + var expParams = context.AvatarDescriptor.expressionParameters; + if (expParams != null && context.IsTemporaryAsset(expParams)) + { + expParams.parameters = expParams.parameters.Where(p => !string.IsNullOrEmpty(p.name)).ToArray(); + } + } + } +} \ No newline at end of file diff --git a/Editor/OptimizationPasses/PruneParametersPass.cs.meta b/Editor/OptimizationPasses/PruneParametersPass.cs.meta new file mode 100644 index 00000000..c36e34b9 --- /dev/null +++ b/Editor/OptimizationPasses/PruneParametersPass.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 81c7d9255ba848e4be29b291bc086ed6 +timeCreated: 1703573974 \ No newline at end of file diff --git a/Editor/PluginDefinition/PluginDefinition.cs b/Editor/PluginDefinition/PluginDefinition.cs index e2796c9f..0d9b5d32 100644 --- a/Editor/PluginDefinition/PluginDefinition.cs +++ b/Editor/PluginDefinition/PluginDefinition.cs @@ -30,7 +30,7 @@ namespace nadena.dev.modular_avatar.core.editor.plugin seq.Run("Clone animators", AnimationUtil.CloneAllControllers); seq = InPhase(BuildPhase.Transforming); - seq.Run("Validate configuration", + seq.Run("Validate configuration", context => ComponentValidation.ValidateAll(context.AvatarRootObject)); seq.WithRequiredExtension(typeof(ModularAvatarContext), _s1 => { @@ -83,6 +83,7 @@ namespace nadena.dev.modular_avatar.core.editor.plugin UnityEngine.Object.DestroyImmediate(component); } }); + seq.Run(PruneParametersPass.Instance); }); InPhase(BuildPhase.Optimizing)