diff --git a/Editor/Inspector/Menu/MenuItemGUI.cs b/Editor/Inspector/Menu/MenuItemGUI.cs index 30439a32..8f4ab313 100644 --- a/Editor/Inspector/Menu/MenuItemGUI.cs +++ b/Editor/Inspector/Menu/MenuItemGUI.cs @@ -301,10 +301,9 @@ namespace nadena.dev.modular_avatar.core.editor EditorGUILayout.BeginVertical(); if (_type.hasMultipleDifferentValues) return; - VRCExpressionsMenu.Control.ControlType type = - (VRCExpressionsMenu.Control.ControlType) Enum - .GetValues(typeof(VRCExpressionsMenu.Control.ControlType)) - .GetValue(_type.enumValueIndex); + var controlTypeArray = Enum.GetValues(typeof(VRCExpressionsMenu.Control.ControlType)); + var index = Math.Clamp(_type.enumValueIndex, 0, controlTypeArray.Length - 1); + var type = (VRCExpressionsMenu.Control.ControlType)controlTypeArray.GetValue(index); switch (type) { diff --git a/Editor/Menu/MenuExtractor.cs b/Editor/Menu/MenuExtractor.cs index 89ee232c..9f670382 100644 --- a/Editor/Menu/MenuExtractor.cs +++ b/Editor/Menu/MenuExtractor.cs @@ -119,9 +119,11 @@ namespace nadena.dev.modular_avatar.core.editor internal static VRCExpressionsMenu.Control CloneControl(VRCExpressionsMenu.Control c) { + var type = c.type != 0 ? c.type : VRCExpressionsMenu.Control.ControlType.Button; + return new VRCExpressionsMenu.Control() { - type = c.type, + type = type, name = c.name, icon = c.icon, parameter = new VRCExpressionsMenu.Control.Parameter() { name = c.parameter?.name },