No more will my objects fall off the world screen! Good god, I love the internet, it really makes my life easier.
So, what I was missing was the Camera.main.ViewportToWorldPoint function. It can be used to pull the edges of the screen, so that even if I switch my resolution, the borders will stay true for that resolution. So, here it is: A bordered world for my little white square
var leftBorder = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, 0)).x;
if (transform.position.x > leftBorder)
transform.position += Vector3.left * speed * Time.deltaTime;
Now, there is a little problem… If my speed is too high, lets say 20 (its 5 now), it’s possible that my little square can jump 19 pixels off the screen if the center is only 1 pixel away from the border.
So, next step? Make it so that if it would disappear, force it at the the edge. How to do this? I have a couple ideas. I’ll be back later on that!