Example Usage

Updated 3 months ago
using ArmSlider; // etc

public class MyMod : MelonMod
{
    Slider.Setting settingOne;
    Slider.Setting settingTwo;
    bool doneInit = false;

    public override void OnSceneWasLoaded(int buildIndex, string sceneName)
    {
        if (!doneInit && sceneName == "Gym")
        {
            // Initialise slider settings
            settingOne = Slider.AddSetting("Cool Setting", "This setting is printed to the console whenever you move the slider.", 0.0f, 100.0f, 0.0f);
            settingTwo = Slider.AddSetting("Important Setting", "This setting does important things.", 0.0f, 1.0f, 0.0f, 2);
            settingOne.ValueChanged += OnSettingOneMoved;
            settingTwo.ValueChanged += OnSettingTwoMoved;
            doneInit = true;
        }
    }

    public void OnSettingOneMoved(object sender, Slider.ValueChangedEventArgs args)
    {
        MelonLogger.Msg("Sender is settingOne: " + (Slider.Setting)sender == settingOne); // True
        MelonLogger.Msg("Value: " + args.Value); // An integer between 0 and 100
    }

    public void OnSettingTwoMoved(object sender, Slider.ValueChangedEventArgs args)
    {
        // Immediately deactivate the slider whenever the player tries to grab it
        settingTwo.Active = false;
    }
}