Profile image

Unity modding bug

Dev WNP78  7.8 years ago

Bug:

When using a slider for custom part modifiers, the numberOfSteps argument does not affect the actual number of steps. Therefore, all sliders are to 4 decimal places.

  • Log in to leave a comment
  • Profile image
    Dev WNP78

    my code:
    [DesignerPropertySlider(0f,1000,1000,Label = "Fixed Distance",Order = 102)]
    public int fixedDist;
    it goes up in 1000s?
    @NathanMikesa

    7.8 years ago
  • Profile image

    I think I misunderstood... The number of steps controls the increments for the slider. for example a slider from 1 to 5 with 5 steps will allow you to set it to 1, 2, 3, 4, or 5. The same slider with 50 steps will increment in small decimals, allowing 50 different positions for the slider. The formatting of the number is somewhat unrelated.

     

    If you need to format the number/label (such as limit it to two decimal places), you can override the 'GetDesignerPropertySliderValueLabel' method on the modifier. For example...

    [DesignerPropertySlider(1, 5, 50)]
    public int SliderTestProperty;
    
    public override string GetDesignerPropertySliderValueLabel(string propertyName, float sliderValue)
    {
        if (propertyName == "SliderTestProperty")
        {
            return sliderValue.ToString("F2");
        }
    
        return base.GetDesignerPropertySliderValueLabel(propertyName, sliderValue);
    }
    
    7.8 years ago
  • Profile image

    I was not aware of this issue. I've logged it and will hopefully investigate it in the near future. Thanks for letting me know.

    7.8 years ago
  • Profile image
    Dev WNP78

    @nathanmikesa ?
    this has existed for a while

    7.8 years ago