Display problem with OnGUI

Hello everybody please i want to display a Gui after another but it didn’t work does Unity don’t allow this ??

Here’s my code

void OnGUI()
{

DisplayProfils()

}

void DisplayProfils()

{
    GUI.BeginGroup(new Rect(Screen.width*0.3f,Screen.height*0.2f,Screen.width*0.5f,Screen.height*0.5f));
    GUI.Box(new Rect(0,0,Screen.width*0.5f,Screen.height*0.5f),"Choix du profil");
    if(GUI.Button(new Rect(Screen.width*0.2f,70,150,50),"profil1") )
    {
        CreateNewProfil();
       
    }       
   
    GUI.EndGroup();
   
}
   
   
void CreateNewProfil()
{
    GUI.BeginGroup(new Rect(Screen.width*0.3f,Screen.height*0.4f,Screen.width*0.3f,Screen.height*0.5f));
    GUI.Box(new Rect(0,0,Screen.width*0.3f,Screen.height*0.3f),"Crer votre profil");
    GUI.Button(new Rect(Screen.width*0.2f,70,150,50),"profil1");
    print("POP");
    GUI.EndGroup();
}

the CreateNewProfil() don’t display when i click the button , can i make something to fix it?

Thank you

You have to continuously execute it within the OnGUI function. Use a boolean which is set to false until you click the button, then within the OnGUI have an if-statement which only executes if the boolean is true.

I have made it in a function OnGUI i haven’t mention it in the code but here what i have made

void OnGUI()				
{
	GUI.skin=mySkin;
	
	
	//CheckProfilExist();		
	DisplayProfils);			
	
}

But the problem stay the same i can’t display a Gui upon another, only one Gui at the same time

Try something like:

enum Pages {
profiles,
new_profile
}

Pages current = Pages.profiles;

void OnGUI()
{
switch(current)
{
case profiles: DisplayProfils(); break;
case new_profile: CreateNewProfil(); break;
}
}


then change 
if(GUI.Button(new Rect(Screen.width*0.2f,70,150,50),"profil1") )
{
	//CreateNewProfil();
	current = Pages.new_profile;
}