From 4e576465c21f6a6834218c982a817b2782f5789d Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 3 Mar 2026 18:52:36 -0800 Subject: Support multiple YOTS instances on one avatar --- Scripts/YOTSNDMFGenerator.cs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Scripts/YOTSNDMFGenerator.cs b/Scripts/YOTSNDMFGenerator.cs index f8cf889..4471fa1 100644 --- a/Scripts/YOTSNDMFGenerator.cs +++ b/Scripts/YOTSNDMFGenerator.cs @@ -40,19 +40,27 @@ namespace YOTS // Transforming phase, we can no longer access the YOTSConfig object. InPhase(BuildPhase.Resolving) .Run("Cache YOTS Config", ctx => { - var config = ctx.AvatarRootObject.GetComponentInChildren(); - if (config == null) { + var configs = ctx.AvatarRootObject.GetComponentsInChildren(); + if (configs.Length == 0) { ctx.GetState().skipGeneration = true; Debug.Log("No YOTS config found - skipping."); return; } - if (config.jsonConfig == null) { - ctx.GetState().skipGeneration = true; - ErrorReport.ReportError(lcl, ErrorSeverity.Error, "json_missing", - ctx.AvatarRootObject); - return; + var mergedConfig = new AnimatorConfigFile(); + foreach (var config in configs) { + if (config.jsonConfig == null) { + ctx.GetState().skipGeneration = true; + ErrorReport.ReportError(lcl, ErrorSeverity.Error, "json_missing", + config.gameObject); + return; + } + var parsed = JsonUtility.FromJson(config.jsonConfig.text); + mergedConfig.toggles.AddRange(parsed.toggles); + if (parsed.api_version != null) { + mergedConfig.api_version = parsed.api_version; + } } - ctx.GetState().jsonConfig = config.jsonConfig.text; + ctx.GetState().jsonConfig = JsonUtility.ToJson(mergedConfig); }) // Shoutsout anatawa12/AvatarOptimizer .BeforePass(RemoveEditorOnlyPass.Instance); -- cgit v1.2.3