diff options
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | Scripts/YOTSCore.cs | 35 | ||||
| -rw-r--r-- | Scripts/YOTSNDMFGenerator.cs | 14 |
3 files changed, 30 insertions, 22 deletions
@@ -68,7 +68,8 @@ Toggle options are documented in two places: * Radial puppets (sliders) are created as float parameters. * All parameters are synced and saved by default. * You can override this with the `synced` and `saved` flags. -* Menus are always placed under /YOTS. +* YOTS will not stop you from over-filling menus. + * Auto-splitting menus is not yet implemented. * The generated VRChat parameter and animator parameters use the "name" field. No namespacing is applied. * The generated animator has exactly as many layers as the maximum length of diff --git a/Scripts/YOTSCore.cs b/Scripts/YOTSCore.cs index 4ec3343..e7608e4 100644 --- a/Scripts/YOTSCore.cs +++ b/Scripts/YOTSCore.cs @@ -45,7 +45,7 @@ namespace YOTS // /YOTS. So if you put "Clothes" here, it'll be placed under
// /YOTS/Clothes.
[SerializeField]
- public string menuPath = "/";
+ public string menuPath = "/YOTS";
// The default value of the toggle. Range from 0-1.
// For example, if you want a gimmick to start toggled off, set this to
@@ -818,6 +818,7 @@ namespace YOTS .Select(g => g.First())
.ToList();
+ // Update parameters
var paramList = new List<VRCExpressionParameters.Parameter>();
paramList.AddRange(vrcParams.parameters.Where(p => !uniqueToggles.Any(t => t.name == p.name)));
foreach (var toggle in uniqueToggles) {
@@ -830,22 +831,23 @@ namespace YOTS });
}
vrcParams.parameters = paramList.ToArray();
- vrcMenu.controls.RemoveAll(c => c.name == "YOTS");
- // Create YOTS submenu
- VRCExpressionsMenu yotsSubmenu = ScriptableObject.CreateInstance<VRCExpressionsMenu>();
- yotsSubmenu.name = "YOTS";
- yotsSubmenu.controls = new List<VRCExpressionsMenu.Control>();
+
+ // Add toggles to menu
foreach (var toggle in toggleSpecs) {
- VRCExpressionsMenu currentMenu = yotsSubmenu;
- // Recursively create menus until we wind up at the leaf.
- if (!string.IsNullOrEmpty(toggle.menuPath) && toggle.menuPath != "/") {
+ VRCExpressionsMenu currentMenu = vrcMenu;
+
+ // Navigate or create menu path if specified
+ if (!string.IsNullOrEmpty(toggle.menuPath)) {
string trimmedPath = toggle.menuPath.Trim('/');
- var sections = trimmedPath.Split('/');
- foreach (var section in sections) {
- currentMenu = GetOrCreateSubmenu(currentMenu, section);
+ if (!string.IsNullOrEmpty(trimmedPath)) {
+ var sections = trimmedPath.Split('/');
+ foreach (var section in sections) {
+ currentMenu = GetOrCreateSubmenu(currentMenu, section);
+ }
}
}
- // Add toggle.
+
+ // Add toggle control
if (toggle.type == "radial") {
currentMenu.controls.Add(new VRCExpressionsMenu.Control{
name = toggle.name,
@@ -863,13 +865,6 @@ namespace YOTS });
}
}
-
- // Add YOTS submenu to main menu.
- vrcMenu.controls.Add(new VRCExpressionsMenu.Control{
- name = "YOTS",
- type = VRCExpressionsMenu.Control.ControlType.SubMenu,
- subMenu = yotsSubmenu
- });
}
}
}
diff --git a/Scripts/YOTSNDMFGenerator.cs b/Scripts/YOTSNDMFGenerator.cs index 525953c..602c247 100644 --- a/Scripts/YOTSNDMFGenerator.cs +++ b/Scripts/YOTSNDMFGenerator.cs @@ -90,7 +90,7 @@ namespace YOTS return;
}
// Create copies so the originals don't get modified
- menu = UnityEngine.Object.Instantiate(menu);
+ menu = DeepCopyMenu(menu);
parameters = UnityEngine.Object.Instantiate(parameters);
descriptor.expressionsMenu = menu;
descriptor.expressionParameters = parameters;
@@ -166,6 +166,18 @@ namespace YOTS private class YOTSBuildState {
public string jsonConfig;
}
+
+ private static VRCExpressionsMenu DeepCopyMenu(VRCExpressionsMenu sourceMenu) {
+ var copiedMenu = UnityEngine.Object.Instantiate(sourceMenu);
+ // Deep copy all submenu references
+ for (int i = 0; i < copiedMenu.controls.Count; i++) {
+ var control = copiedMenu.controls[i];
+ if (control.type == VRCExpressionsMenu.Control.ControlType.SubMenu) {
+ control.subMenu = DeepCopyMenu(control.subMenu);
+ }
+ }
+ return copiedMenu;
+ }
}
}
|
