I have a GUI panel that I display on top of existing GUI buttons. At the end of the GUI layout function, I have added some code to consume any input related event so as not to let them propagate to the buttons on the GUI layer behind this panel.
This used to work a couple of weeks ago but with the latest update it seems to not have any effect: when my panel is open, I can still click on invisible UI elements behind it (and start the game from my option menu…). I am not entirely sure if the problem comes from recent changes in my code or a bug introduced in one of the last updates of Unity. So in doubt, I’m asking here first if anyone else is having this problem.
Here’s a snippet of my code:
protected override void OnGUI()
{
base.OnGUI();
BeginPanel( screen.ToString() );
GUILayout.Space( titleSpacing );
if( screen == Screen.Credits )
LayoutCreditScreen();
else
LayoutOptionScreen();
GUILayout.FlexibleSpace();
if( GUILayout.Button( "Back", GUILayout.Height( buttonsHeight ) ) )
{
Game.UI.PlayDeactivationSound();
if( screen == Screen.Options )
Destroy( this.gameObject );
else
screen = Screen.Options;
}
EndPanel();
switch( Event.current.type )
{
case EventType.MouseDown:
case EventType.MouseUp:
case EventType.MouseDrag:
Event.current.Use();
break;
}
}
Let me know if more details are needed.