Hi Guys,
Simple question. In the Scrollbar’s editor section you’re able to give it steps. The maximum steps number is 11. I want more than that. Possibly 20-40 steps. Is there a way to do this? Thanks!
Hi Guys,
Simple question. In the Scrollbar’s editor section you’re able to give it steps. The maximum steps number is 11. I want more than that. Possibly 20-40 steps. Is there a way to do this? Thanks!
Nope, you are right. It seems the current default control is hard locked at 11.
If you want more, then either download the source and alter the max in the slider script and replace your Unity UI dll’s (as instructed on the Open Source bitbucket page)
Or just copy the slider script, rename it (and the class names) and make your own version.
https://bitbucket.org/Unity-Technologies/ui/src/5fc21bb4ecf4b40ff6630057edaa070252909b2e/UnityEngine.UI/UI/Core/Scrollbar.cs?at=4.6
In Unity 5.3.4 (may be earlier versions too) you can change number of steps to any value by switching property editor to “Debug mode”. Edit number of steps then switch back to “Normal mode”. It will leave as you set. If you try to change again in Normal mode, it will reset to 11.
I think it is a bug, not a feature.
The Slider class does support being extended. I would suggest something similar to the following:
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class JC_Slider : Slider
{
public float StepsIncrement = .1f;
public override void OnMove(AxisEventData eventData)
{
if((direction == Direction.RightToLeft || direction == Direction.LeftToRight) &&
(eventData.moveDir == MoveDirection.Left || eventData.moveDir == MoveDirection.Right))
{
this.value += eventData.moveDir == MoveDirection.Left ? -StepsIncrement : StepsIncrement;
return;
}
if ((direction == Direction.BottomToTop || direction == Direction.TopToBottom) &&
(eventData.moveDir == MoveDirection.Down || eventData.moveDir == MoveDirection.Up))
{
this.value += eventData.moveDir == MoveDirection.Down ? -StepsIncrement : StepsIncrement;
return;
}
base.OnMove(eventData);
}
}
Change the file permission of C:\Program Files\Unity\Hub\Editor\2020.3.6f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\Scrollbar.cs;
Then change the setting of line 114, as below (change 11 to the value you want):
[Range(0, 110)]
[SerializeField]
private int m_NumberOfSteps = 0;
2024 and this is still an issue!
Hello 2025! This is still pretty lame that the steps are still limited at 11.