summaryrefslogtreecommitdiffstats
path: root/Scripts/YOTSNDMFGenerator.cs
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-03-03 18:52:36 -0800
committeryum <yum.food.vr@gmail.com>2026-03-03 18:52:36 -0800
commit4e576465c21f6a6834218c982a817b2782f5789d (patch)
tree7cbbe1865673ab3f4661e74ce359b08b6d27efad /Scripts/YOTSNDMFGenerator.cs
parent2e6f64192c4e882f6d312161b215128fc3f4fd1d (diff)
Support multiple YOTS instances on one avatar
Diffstat (limited to 'Scripts/YOTSNDMFGenerator.cs')
-rw-r--r--Scripts/YOTSNDMFGenerator.cs24
1 files 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<YOTSConfig>();
- if (config == null) {
+ var configs = ctx.AvatarRootObject.GetComponentsInChildren<YOTSConfig>();
+ if (configs.Length == 0) {
ctx.GetState<YOTSBuildState>().skipGeneration = true;
Debug.Log("No YOTS config found - skipping.");
return;
}
- if (config.jsonConfig == null) {
- ctx.GetState<YOTSBuildState>().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<YOTSBuildState>().skipGeneration = true;
+ ErrorReport.ReportError(lcl, ErrorSeverity.Error, "json_missing",
+ config.gameObject);
+ return;
+ }
+ var parsed = JsonUtility.FromJson<AnimatorConfigFile>(config.jsonConfig.text);
+ mergedConfig.toggles.AddRange(parsed.toggles);
+ if (parsed.api_version != null) {
+ mergedConfig.api_version = parsed.api_version;
+ }
}
- ctx.GetState<YOTSBuildState>().jsonConfig = config.jsonConfig.text;
+ ctx.GetState<YOTSBuildState>().jsonConfig = JsonUtility.ToJson(mergedConfig);
})
// Shoutsout anatawa12/AvatarOptimizer
.BeforePass(RemoveEditorOnlyPass.Instance);