Get current mouse position ONCE.

So I am trying to make a GUI button appear when pressing a button (plus some other things, but thats not important), but I need it to appear when I press a button (in this case, right mouse button) and appear where my mouse was when I clicked, and not follow the cursor. (kind of similar to the right click menu in Windows and Mac)

GUI.Button(Rect(Event.current.mousePosition.x,Event.current.mousePosition.y,50,50),"");

This code here makes it follow the cursor, how would I make it so it only gets the position when it is first called?

(BTW, the code may be a little wrong, I wrote it from the top of my head.)

Once you press the right mouse button, do:

float posX = Event.current.mousePosition.x;
//the same for Y

Now the position values are saved and won’t change, so do

GUI.Button(new Rect(posX, posY, 50, 50), "");

Hope that works!