Search Unity

make a slider read only

Discussion in 'Immediate Mode GUI (IMGUI)' started by Mike L, Jan 9, 2011.

  1. Mike L

    Mike L

    Joined:
    Sep 14, 2010
    Posts:
    1,035
    basically what the title says.
     
  2. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    Read only in what sense? The slider displays the current value, but cannot be adjusted? Or the slider "snaps" to a mid point and can be adjusted as an offset of that midpoint?

    If "vSliderValue = GUI.VerticalSlider (Rect (25, 25, 100, 30), vSliderValue, 10.0, 0.0);" is a read/write slider, then simply removing the vSliderValue = like this...

    GUI.VerticalSlider (Rect (25, 25, 100, 30), vSliderValue, 10.0, 0.0);

    Would be a "read only" slider in the sense that it displays the proper value but does not "slide" (the user cannot change).

    Doing a snap slider would be a little more difficult; basically you'd have to detect when the mouse started interacting with the slider and when it stopped. Whenever you have a mouse up event over the slider you'd reset the min/max/midpoint values.
     
  3. Mike L

    Mike L

    Joined:
    Sep 14, 2010
    Posts:
    1,035
    never mind, I figure it out. i used :
    Code (csharp):
    1. GUI.enabled = false;
     
  4. andrenospam0

    andrenospam0

    Joined:
    Oct 28, 2018
    Posts:
    6
    In your slider object, uncheck interactable
     
    Fire_Frog_Studio likes this.