summaryrefslogtreecommitdiffstats
path: root/Scripts/YOTSCore.cs
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-02-19 16:16:39 -0800
committeryum <yum.food.vr@gmail.com>2025-02-19 16:16:39 -0800
commit0d50a7e8483d97e03cae8050732df83eba33f31f (patch)
treeed7e79681388825742aa9fc64a20a5f4dc490aa8 /Scripts/YOTSCore.cs
parent63b60932ba5500d0c26c3237705edd896c8a4d6f (diff)
Menus no longer implicitly go under /YOTS
Diffstat (limited to 'Scripts/YOTSCore.cs')
-rw-r--r--Scripts/YOTSCore.cs35
1 files changed, 15 insertions, 20 deletions
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
- });
}
}
}