Slider with filter option
so, I'm designing a game in which I want to sell apartments. the thing is, like on every other site which does so, I want to put in a slider for the price and see the results that fit my needs.
for example, I want to have a slider with the values of 0 - 50€/m2 and click e.g on 20 and I want the game to show me only the apartments whose price is lower that 20. is that possible to make in Unity?
Answer by mybluesock · May 08, 2017 at 07:24 PM
A slider just allows you to manipulate one variable. You give it an upper and lower bound and a default value, and then you can access it's current value whenever it gets changed to update your list/array of apartments. I'm not sure how to create a slider with two drag-able handles so you can set the upper and lower end of the range, but I'm sure it's doable, and you could just as easily use two sliders.
Answer by Toreole · Sep 27, 2017 at 04:25 PM
eminadiz
A way to do this would be to have an array or a list of the appartment components / objects . Then you basically make a copy of that array/list with the condition that the price is under the limit you set with the slider
[...] Slider limit;
[...]{
List<Appartment> suitedApparts = new List<Appartment>();
foreach(Appartment appartment in [AllAvailableApparments]){
if(appartment.price <= limit.value){
suitedApparts.Add(appartment);
}
}
}
Your answer
Follow this Question
Related Questions
Slider with filter / search engine -1 Answers
How do I take out a UI Slider's value? 0 Answers
lerp a float value of keyup 2 Answers
Slider value help 0 Answers
Make a 2D side panel in a 3D game 1 Answer