Skip to content

Commit

Permalink
Check if expression menu is null
Browse files Browse the repository at this point in the history
  • Loading branch information
SaracenOne committed Aug 4, 2022
1 parent 91414f3 commit 09b3fea
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Editor/VRC3CVR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,24 +388,26 @@ void MatchAnimatorParameterToVRCParameter(VRCExpressionParameter vrcParam) {
chilloutAnimatorController.parameters = parameters;
}
Dictionary<string, Dictionary<int, string>> FindMenuButtonsAndToggles(VRCExpressionsMenu menu, Dictionary<string, Dictionary<int, string>> toggleTable) {
foreach (VRCExpressionsMenu.Control control in menu.controls) {
if (control.type == VRCExpressionsMenu.Control.ControlType.Toggle || control.type == VRCExpressionsMenu.Control.ControlType.Button) {
Dictionary<int, string> idTable;
if(toggleTable.ContainsKey(control.parameter.name)) {
idTable = toggleTable[control.parameter.name];
} else {
idTable = new Dictionary<int, string>();
}

if (!idTable.ContainsKey((int)control.value)) {
idTable.Add((int)control.value, control.name);
}

toggleTable[control.parameter.name] = idTable;
} else if (control.type == VRCExpressionsMenu.Control.ControlType.SubMenu) {
toggleTable = FindMenuButtonsAndToggles(control.subMenu, toggleTable);
}
}
if (menu != null) {
foreach (VRCExpressionsMenu.Control control in menu.controls) {
if (control.type == VRCExpressionsMenu.Control.ControlType.Toggle || control.type == VRCExpressionsMenu.Control.ControlType.Button) {
Dictionary<int, string> idTable;
if(toggleTable.ContainsKey(control.parameter.name)) {
idTable = toggleTable[control.parameter.name];
} else {
idTable = new Dictionary<int, string>();
}

if (!idTable.ContainsKey((int)control.value)) {
idTable.Add((int)control.value, control.name);
}

toggleTable[control.parameter.name] = idTable;
} else if (control.type == VRCExpressionsMenu.Control.ControlType.SubMenu) {
toggleTable = FindMenuButtonsAndToggles(control.subMenu, toggleTable);
}
}
}

return toggleTable;
}
Expand Down

0 comments on commit 09b3fea

Please sign in to comment.