Search Unity

disable mouse

Discussion in 'Immediate Mode GUI (IMGUI)' started by BlueMumm, Apr 8, 2008.

  1. BlueMumm

    BlueMumm

    Joined:
    Feb 7, 2008
    Posts:
    43
    I was wanting to know if there is a way to disable mouse on the GUI Slider?
     
  2. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    You could simply test if the returned float differs from the value float and if so hide the cursor using

    Screen.showCursor = false;

    ... and then show it again only when the mouse button is no longer pressed.

    Ex - in OnGUI:
    Code (csharp):
    1. float oldValue;
    2.  
    3. oldValue = value;
    4. value = GUI.VerticalSlider( sliderRect, value, topValue, bottomValue );
    5. if( value != oldValue )
    6. {
    7.     hiddenByGUI = true;
    8.     Screen.showCursor = false;
    9. }
    10.  
    and in Update:
    Code (csharp):
    1. if( hiddenByGUI  !Input.GetMouseButton( 0 ) )
    2. {
    3.     hiddenByGUI = false;
    4.     Screen.showCursor = true;
    5. }
     
  3. BlueMumm

    BlueMumm

    Joined:
    Feb 7, 2008
    Posts:
    43
    I gave that a try still is able to mess around with the GUI Slider after hidden.
     
  4. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Ah sorry I misunderstood. In that case you should simply not store the returned float value.
     
  5. BlueMumm

    BlueMumm

    Joined:
    Feb 7, 2008
    Posts:
    43
    Great got it working thanks :)