Search Unity

GUI.DrawTexture overlay behind a gui.window - stop input events propagating through

Discussion in 'Immediate Mode GUI (IMGUI)' started by jpilon, Dec 30, 2013.

  1. jpilon

    jpilon

    Joined:
    Dec 14, 2013
    Posts:
    8
    Hello,

    I have an in-game pause menu all designed etc using unity's gui. Behind the pause menu I drew a 1x1 semi transparent texture (texture is just a black 1x1 png stretched to fill screen).

    Problem is, click events (I'm assuming touch events too) pass right through the texture. This is a big issue for me, does anyone know a way around this problem?

    I have tried GUI.ModalWindow and it does prevent clicks on other gui elements underneath the overlay, but for some reason other game pieces are still clickable.

    Code (csharp):
    1.  
    2.             GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,pauseAlpha);
    3.             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadePixel);
    4.                         // restore alpha to rest of gui
    5.             GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,GameScreens[0].Alpha);
    6.