Let's say I want a button to always be at the top left of the screen in a game with movable camera and togglable full screen.

I can make the button stay at the top left by making it a child of the Camera2D node so that the movement of the camera is negated, that's no problem.

However, when the button is a child of the camera, this script: OS.window_fullscreen = !OS.window_fullscreen Makes it so that a large margin gets created between the button and the physical borders of the screen.

Non-fullscreen:

(Fullscreen version can't be screenshotted properly due to unknow reason)

So, how can I make the button stay on the top left of the window, regardless of size?

Hang on, I'm still learning about the UI myself but it's worth pointing out if you make any kind of UI element a child of the camera if you have following behaviour enabled or make any kind of changes in runtime the UI will copy it. You should look up how to use a canvas layer in your hierarchy setup so you don't run into problems later on, have you tried enabling follow viewport as well with a canvas layer? That might be what you're looking for but I'm still learning this myself.

Edit: Nevermind follow viewport doesn't do what I think it does, but I do recommend setting up with canvas layer.

@cybereality said: You would use Control nodes to setup the UI. For example a VBox or HBox with the proper size flags and layout options.

Also anchoring!

6 months later