I feel like this should be a simple question, but I’m so deep in my code I can only come up with ‘complex’ solutions…
I have a GUI.HorizontalSlider for the user to control. When they press a button, the code runs to check if their hSliderValue is equal to the puzzleValue. If yes, I want to LOCK the GUI.HorizontalSlider so they can no longer change their submitted hSliderValue (but keep the slider on the screen while they play with other variables).
My assumption is that setting the enabled value of GUI to false prior to drawing your slider. Then if the other elements are not supposed to be locked, set it back to true.
The newer GUI sytem included in Unity 4.6 requires a somewhat different method; set the boolean “interactable” to false on the object which should be disabled (or on a canvas group that contains it). But you don’t seem to be using that.
Here is an example of how the code could look:
[SerializeField]
private int puzzleValue;
private int value;
private bool lockSlider = false;
private void OnGUI()
{
if (GUI.Button(new Rect(),"Test"))
if (puzzleValue == value)
lockSlider = true;
GUI.enabled = !lockSlider;
value = (int)GUI.HorizontalSlider(new Rect(), value, 0, 10);
GUI.enabled =true;
}