/// <summary> /// Add a toggle button pedal to an ActionMenu page /// </summary> /// <param name="pageType">The page to add the button to</param> /// <param name="text">Button text</param> /// <param name="startingState">Starting value of the toggle pedal everytime the pedal is created</param> /// <param name="onToggle">Calls action with a bool depending on the current value of the toggle</param> /// <param name="icon">(optional) The Button Icon</param> /// <param name="locked">(optional)The starting state for the lockable pedal, true = locked, false = unlocked</param> /// <param name="insertion"> /// (optional) Determines whether or not the button is added before or after VRChat's buttons for /// the target page /// </param> public static PedalToggle AddToggle(ActionMenuPage pageType, string text, bool startingState, Action <bool> onToggle, Texture2D icon = null, bool locked = false, Insertion insertion = Insertion.Post) { var pedal = new PedalToggle(text, onToggle, startingState, icon, locked); AddPedalToList(pageType, pedal, insertion); return(pedal); }
public static void AddPedalsInList(List <PedalStruct> list, ActionMenu instance) { foreach (var pedalStruct in list) { PedalOption pedalOption = instance.AddOption(); switch (pedalStruct.Type) { case PedalType.Button: pedalOption.setText(pedalStruct.text); pedalOption.setIcon(pedalStruct.icon); pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate <PedalOptionTriggerEvent>(pedalStruct.triggerEvent); break; case PedalType.SubMenu: pedalOption.setText(pedalStruct.text); pedalOption.setIcon(pedalStruct.icon); pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = GetExpressionsIcons().typeFolder; pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate <PedalOptionTriggerEvent>(pedalStruct.triggerEvent); break; case PedalType.RadialPuppet: PedalRadial pedalRadial = (PedalRadial)pedalStruct; pedalOption.setText(pedalStruct.text); pedalOption.setIcon(pedalStruct.icon); pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = GetExpressionsIcons().typeRadial; pedalOption.field_Public_ActionButton_0.prop_String_1 = $"{Math.Round(pedalRadial.currentValue)}%"; pedalRadial.pedal = pedalOption; pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate <PedalOptionTriggerEvent>(pedalStruct.triggerEvent); break; case PedalType.Toggle: PedalToggle pedalToggle = (PedalToggle)pedalStruct; pedalOption.setText(pedalStruct.text); if (pedalToggle.toggled) { pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = GetExpressionsIcons().typeToggleOn; } else { pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = GetExpressionsIcons().typeToggleOff; } pedalOption.setIcon(pedalToggle.icon); pedalToggle.pedal = pedalOption; pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate <PedalOptionTriggerEvent>(pedalStruct.triggerEvent); break; case PedalType.FourAxisPuppet: pedalOption.setText(pedalStruct.text); pedalOption.setIcon(pedalStruct.icon); pedalOption.field_Public_ActionButton_0.prop_Texture2D_2 = GetExpressionsIcons().typeAxis; pedalOption.field_Public_MulticastDelegateNPublicSealedBoUnique_0 = DelegateSupport.ConvertDelegate <PedalOptionTriggerEvent>(pedalStruct.triggerEvent); break; } } }