Change the position of a UI component through pressing a UI Button

Hello,
I’ve been trying to make my options menu. Basicly I have a series of UI components making an options window, which is first with Z position -1 so players can’t see it. When the player presses the options button the Z position changes to 1 and vise versa. Im having a lot of headaches with this.
Can someone help?

You can make the UI elements to be children to a gameobject. Then you can change the Z position of the parent gameobject.

If you want to assign a method to the onClick event of the Button, you can call:

yourButton.onClick.AddListener(() => YourMethod());

‘yourButton’ should be a Button object, and YourMethod() should be a method in the same script.