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?

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.

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);
      }
   }
}