GUI.Button does not go out of “void OnGui”

following the tutoriel of “Design3d” we learn how to make GUI.Button here in:

void OnGUI()
	{
	
		if (GUI.Button (new Rect(Screen.width - posBagBtn.x, Screen.height - posBagBtn.y, slotSize, slotSize),bagBtnName)){
			ToggleBag();
		}
		if (showBag) {
			Bag (posBagBtn.x, posBagBtn.y, 500, 500); 
		}
}

	public void ToggleBag()
	{
		if (showBag) {
			HideBag ();
		} else {
			ShowBag ();
		}
	}
	
	
	
	public void  HideBag (){
		showBag = false;
	}
	
	public void  ShowBag (){
		showBag = true;
		
	}
	
	public bool BagIsBeingDisplayed(){
		
		return showBag;
	}

it makes us calls with the number of bag creates!
How in the tutoriel I have some create 4 and up to now everything works well!
But if I use the code:

    if (GUI.Button (new Rect(Screen.width - posBagBtn.x, Screen.height - posBagBtn.y, slotSize, slotSize),bagBtnName)){
             ToggleBag();
         }
         if (showBag) {
             Bag (posBagBtn.x, posBagBtn.y, 500, 500); 
         }

Out of the OnGui function and uses it in a function which I have create that walks more I have one bag which appears and it posts me the last of the list… Why?

There is to you it a means of creates several bags in another function that OnGui?

With agreement I knew it is it for that I do not arrived there! There is to you it another means? For creates several bags?

Thank you for your answers rapid!