Make buttons appear

Hello everyone! I’m working on an Android game. I would like to make some buttons appear when the user pushes the pause button. I would like to achieve two other effects also:

  1. the screen becomes darker
  2. the new buttons that appear, appear with a transition effect.

I’m using this code right now:

Simply, if the pause button is pressed make a grey semi-transparent texture fill the screen and make other buttons appear.

function OnGUI () {
    if ((GUI.Button(Rect(100,100, 50, 50), "", "pausebutton"))){
        GUI.DrawTexture(Rect(0,0, Screen.width, Screen.height), ScreenCover, ScaleMode.StretchToFill);
        GUI.Button(Rect(200,200, 50, 50), "", "otherbutton");
    ......and so on..

But this doesn’t work. The semi-transparent texture and the buttons don’t appear when i press the pause button. Second problem, how can i make these buttons appear with some transition effect, like a simple wipe effect, for example? Thanks for your help!

They will appear in one frame only if you use your code this way.

you need to have a boolean variable or something like that… e.g:

bool showStuff = false;

void OnGUI()
{
   if(GUI.Button(....))
  {
     showStuff = true;
  }
  if(showStuff)
  {
    GUI.DrawTexture(....);
    if(GUI.Button(.....))
    {
    }

  }
}

==EDIT==
for transition you can make use of Mathf.Lerp()

e.g. moving a texture on y axis

float slide = 0;
void OnGUI()
{
    slide += Time.deltaTime;
    GUI.DrawTexture(new Rect(xValue,Mathf.Lerp(yValueBeforetransition,yValue,slide),width,height));
}