GUI.Depth text input/button issues


I’m trying to use two separate classes with OnGUI at different depths to try and create a “notice box” that appears when certain things are called in the main script.

The second script is added to a separate gameobject instanced from the first script. The first script has a depth of 1 and the second a depth of 0.

However, the text inputs and button on the first GUI are still able to be edited/clocked respectively despite having another GUI on top of it.

Any help would be appreciated.


Inside the if block with your GUI.Button() or whatever was clicked, Use() the event up:

if (GUI.Button(new Rect(buttonL, buttonT, buttonW, buttonH), "Fire'")) {
    // use up this event, so it will be marked used for the next button
    // ... do something with the event