GUI Button gets created multiple times

Hi
I’m using

function OnGUI() {
if (showBox) {
GUI.DrawTexture(Rect(posX, 50, 500, 600), information);
//print(“created one button!”);

if(GUI.Button(Rect(600 , 610, 80, 30), “close”)) {
showBox = false;
}
}
}

(How do display this as code?)

The button is opaque, which I think indicates, that it gets created more than twice and lying on top of the others.

If I use a variable (posX + 500) for the Buttons xPosition, the button gets created at 2 places. Also the “second” created button is opaque, which I think indicates, that it gets created more than twice and lying on top of the others.
This does not happen to the GUI.draw.
Any Ideas?
I should mention that this script is on several objects which contain the information = Texture2d, depending on the object. If that is interfering, is there an easy way around this?

Also just for my understanding, the GUI objects are not actually objects, but get recreated each frame showBox is true?

This is exactly the reason
if the script runs 3 times (once each for 3 objects) then you will get 3 buttons overlapped.
Your options are something like:
-give the script a public int or vector2 to offset the button in that script instance, in the inspector give each instance a different offset
-manage each instance with another script, and do a foreach(script instance) draw button

I’m doing it like this now:

one Empty holds all OnGUI, I am just passing the texutres and the activation to that script (empty) by the script of the mouse over object.
Is this a good idea?
Vector2 would be x and y?
I think I’m starting to get how Unity handles instances of scripts and static vars.