Search Unity

Slider modification: Two values & Two Handles? How?

Discussion in 'UGUI & TextMesh Pro' started by Christian-Tucker, Apr 26, 2015.

  1. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    I'm in need of a slider indicator, in which I can select two values (A low value and a high value). How can I go about this using the Unity UI. Would need two knobs to drag around
     
    MilenaRocha likes this.
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    You would need to customise your own Slider control for that, the base slider won't do it.

    Shouldn't be too hard through, just adding another handle and then updating the fill logic to work between the two handle positions.
    I'll add a request to the UI Extensions repo (link below) and see if anyone can pick it up.
     
  3. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    I will literally pay for this feature, if someone can do it
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Last edited: Apr 28, 2015
  5. LUPShow

    LUPShow

    Joined:
    Jul 6, 2015
    Posts:
    7
    i am looking for exactly the same thing. maybe someone has developed something similiar so far and wants to share? :)
     
  6. lermy3d

    lermy3d

    Joined:
    Mar 16, 2014
    Posts:
    101
    Hi guys, I already developed this custom component last year for a personal project I was working on, just let me dig into my files and I will share it with you.
     
    MilenaRocha and bitbert like this.
  7. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @SimonDarksideJ and @lermy3d I was just about to do my own implementation for this with two handles on the slider, but didn't want to "reinvent the wheel" if the work is already done. Did either of you find or post the implementation somewhere?
     
  8. lermy3d

    lermy3d

    Joined:
    Mar 16, 2014
    Posts:
    101
    Hi Ben, could you give me a couple of nights, I almost have the publish process finished. I will hit you back when is out, top worst scenario this weekend :)
     
    bitbert likes this.
  9. lermy3d

    lermy3d

    Joined:
    Mar 16, 2014
    Posts:
    101
    Hello Ben, I just submitted the package to the Unity Store so is a matter of time to be approved, I just got the mail from the Unity store and it can take from 5 to 10 business days, and in some cases it can take a bit longer.

    At least is on the his way out!! I will keep you posted.
    Regards
     
    MilenaRocha, bitbert and Ben-BearFish like this.
  10. jcredible

    jcredible

    Joined:
    Dec 4, 2012
    Posts:
    24
    Depending on your requirements, in 5.2, this is quite easy to "fake". I just used two sliders with the attached scripts and placed them on top of each other (removing or changing the background). This ensures that the minimum value never goes past the maximum and the maximum never goes before the minimum.

    That's what I did in my project, feel free to use it if you like:
     

    Attached Files:

    Brijen25, kikesa72, Alverik and 2 others like this.
  11. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Thanks @lermy3d . Can you tell me what you named it so I can check for it when it's available?
     
  12. lermy3d

    lermy3d

    Joined:
    Mar 16, 2014
    Posts:
    101
    Yes is called "Value Range Slider", and is going out for free! :)
     
  13. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    lermy3d and SimonDarksideJ like this.
  14. lermy3d

    lermy3d

    Joined:
    Mar 16, 2014
    Posts:
    101
    Hi guys! I am happy to share with you the Value Range Slider now published on the asset store, please check it out and share your thoughts and feedback, all the best!
     
  15. a2kas

    a2kas

    Joined:
    Jan 14, 2019
    Posts:
    11
    I know that is an old post, but maybe anyone could answer. How to assign those scripts to sliders? I am getting an error when trying to assign them:
    Untitled.png
     
  16. Mike_Chatz

    Mike_Chatz

    Joined:
    Jan 18, 2019
    Posts:
    8
    Hello! Did you find a solution to this? I got the same message. I tried to remove the existing Slider script but then the other Variable does not appear on the object so it gives a warning message.
     
  17. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    That range slider is for the inspector, its not for the UI in game canvas. Anybody knows where i can get one for the game canvas?
     
  18. kikesa72

    kikesa72

    Joined:
    Nov 20, 2015
    Posts:
    9
    Works perfect in unity 2018.
    (Instructions: create 2 sliders, erase the slider script and replaced for the JScript's; activate the debug view to select the "other" slider script and ready)
     
  19. Dover8

    Dover8

    Joined:
    Aug 20, 2010
    Posts:
    94
    psycodex likes this.
  20. BBJPChroma

    BBJPChroma

    Joined:
    Nov 8, 2017
    Posts:
    4
    Thanks for this! It's awesome. Possibly found a bug - I'm not able to assign rangeSlider.HighValue via script. Is this known? LowValue works as expected, but HighValue displays the Inspector value until it is modified by the user.

    Code (CSharp):
    1. rangeSlider.HighValue = PlayerPrefs.GetInt("myHighValue", 1);
    2.  
     
  21. brinis2023

    brinis2023

    Joined:
    May 24, 2019
    Posts:
    2

    Attached Files:

  22. tpychev

    tpychev

    Joined:
    Jul 24, 2020
    Posts:
    3
    Thank you, your solution helped me a lot.
    Also I found this but couldn't get it to run. Later I saw that there was an example.
     
  23. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    674

    Attached Files:

    Elmstrom, kaiyum and ivantroho_unity like this.
  24. All_American

    All_American

    Joined:
    Oct 14, 2011
    Posts:
    1,528
    @bobadi

    How about a third handle along with the min and max?
     
  25. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    674
    don't know what you mean. it is not my package, I just rewritten some lines for .NET 3.5 (or whatever is used) in Unity 5.6

    it is possible to use separate sliders for min and max, above each other, though

    you mean handle that moves within min-max range, that would be possible too (setting the limits in code) I guess
     
    Last edited: Jun 8, 2021
    All_American likes this.
  26. All_American

    All_American

    Joined:
    Oct 14, 2011
    Posts:
    1,528
    Yep, just finished building it.
     
  27. ivantroho_unity

    ivantroho_unity

    Joined:
    Apr 19, 2020
    Posts:
    1
    kaiyum likes this.
  28. ngfilms

    ngfilms

    Joined:
    Nov 18, 2015
    Posts:
    30
    Just found this , thanks for sharing.