Horizontal slider bug?

Just getting my feet wet with the new GUI stuff… freakin’ awesome, deliciously easy, I love it… but I think I hit a bug… of course the possibility exists that I am doing something stupid. :smiley:

However… when the following code executes, if you drag the Difficulty Slider thus created PAST the right edge of the window, the window pops over to the upper right hand corner, the slider disappears, and a “pushing more clips than popping” error appears. :shock:

GUILayout.BeginArea (setupRect, "Set Up", "window");
		
		GUILayout.Label ("Use Joystick?");
		
		var useJS = GUILayout.Toggle (sys.useJS, "Joystick Enabled");
		if(sys.useJS != useJS)
			{
			sys.switchControlInput(useJS);
			}
			
			if(diffString.length > 0)
				{
				var diffLabel = "Difficulty: " + diffString[diff*diffString.length];
				}
			
			GUILayout.Label (diffLabel);
			diff = GUILayout.HorizontalSlider (diff, 0, 1);
			
		
		if (GUILayout.Button ("OK"))
			{
			sys.setDifficulty(diff);
			mode = "main";
			}
		
		
		
		// And finally, end the area we started with GUILayout.BeginArea...
		GUILayout.EndArea ();

I’ll bet 50 lines of code that the first error in your console is a index out of bounce exception (always look at the first error, anything after that is just cascading errors).

diffString[diff*diffString.length]

When diff = 1 you’r doing diffString[diffString.length], which doesn’t exits since the string indexer is zero-based. Change the line to

diffString[diff*(diffString.length-1)]

Yep, you win 50 lines of code. Duh. I was fooled by the last error message in the console (as you surmised). Thanks for the sanity check.