Search Unity

EditorGUILayout.IntSlider specify step amounts

Discussion in 'Scripting' started by Newcomma, Apr 15, 2016.

  1. Newcomma

    Newcomma

    Joined:
    Feb 10, 2015
    Posts:
    89
    Hi There,

    Ideally I'd like an int slider that goes up in steps of 5 as you slide rather than increments of one. Is it possible to do this? Thanks in advance
     
  2. Newcomma

    Newcomma

    Joined:
    Feb 10, 2015
    Posts:
    89
  3. guillaumeR

    guillaumeR

    Joined:
    Apr 11, 2015
    Posts:
    12
    I don't know if it's possible, but maybe you could just multiply the value of the slider by 5, and use the result instead of the solder value it self.
     
  4. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Not sure if there's an built-in way to do that, but you can simply do the following:

    Code (CSharp):
    1. value = stepping * ((EditorGUILayout.IntSlider(value, 0, 100)) / stepping);
    value = slider value
    stepping = steps you want to have, e.g. 5

    This works as an integer divided by and integer yields an integer value again.