- Home /
How to make if limit is reached then make sliders only slide back in ui (not forward)
any ideas ?
not like that I'm making special system like fallout and I gave 10 points if points reached 0 th make sliders only slide back is it clear now
Use the Slider onValueChanged event to communicate to a controller the value the slider was updated to. The controller will store all of your attributes. You can set a pool of points to add to or deduct from when the controller receives onValueChanged events. If there are no more available points in the pool, reject the value from the slider, ignore further onValueChanged events until you receive a deduction, and reassign the slider value to the one stored in the controller.
Answer by wolfgangmami · Oct 29, 2018 at 02:59 AM
I found solution with myself I added + ve - symbols and I blocked slider controls from user in the red area is all available points and if it's reaches the 10 in the blue area slider reaches the max limit (default limit is 10) and player can only reduces the value
public void special()
{
stlefttxt.text = strength.value.ToString()+" Points";
prlefttxt.text = perception.value.ToString() + " Points";
endulefttxt.text = endurance.value.ToString() + " Points";
chrslefttxt.text = charisma.value.ToString() + " Points";
intellefttxt.text = intelligence.value.ToString() + " Points";
agilefttxt.text = agility.value.ToString() + " Points";
lcklefttxt.text= luck.value.ToString() + " Points";
var a = points.value = strength.value+perception.value+endurance.value+intelligence.value+agility.value+luck.value+charisma.value;
if (points.value==10)
{
errorfeedback.text = "limit";
strength.maxValue = strength.value;
perception.maxValue = perception.value;
endurance.maxValue = endurance.value;
charisma.maxValue = charisma.value;
intelligence.maxValue = intelligence.value;
agility.maxValue = agility.value;
luck.maxValue = luck.value;
}
else
{
strength.maxValue = 10;
perception.maxValue = 10;
endurance.maxValue = 10;
charisma.maxValue = 10;
intelligence.maxValue= 10;
agility.maxValue = 10;
luck.maxValue = 10;
}
pointslefttxt.text=a + " Points";
}
Answer by imran-arif011 · Oct 22, 2018 at 02:26 PM
You can use Unity's UI Extension methods to make them work as you want.
https://www.youtube.com/watch?v=KJlIlWHlfMo
Watch this demo of Unity's UI Extensions. You probably need exact one of these.
You can download them here. https://bitbucket.org/UnityUIExtensions/unity-ui-extensions Hope it helps.