How do you get a minimap to stay rooted to the top left corner of the screen despite resolution changes?

I am making a TBS game and am currently working on the HUD, I have tried different code types and all were unsuccessful.

For example part of the HUD is the minimap that i want to root to the top left corner of the screen, it works for one resolution but when i switch to a different one it appears in a different location.

I have looked through the forums and either the answer doesn’t work or the question is not answered.

What is the best way to fix it?


the top left of the screen is
Camera.main.ViewportToWorldPoint(new vector3(0,1,0));

the top left of the screen and 2 meters forward is

Camera.main.ViewportToWorldPoint(new vector3(0,1,2));

the center of the screen is half way along the x axis and half way along the y axis or
just FYI an ‘f’ after a number makes it a float in case you were unaware.

Camera.main.ViewportToWorldPoint(new vector3(.5f,.5f,0));

hopefully that answers your question.

Viewport functions are independant of the resolution.

(0,0) is the bottom left and (1,1) is the top right regardless of resolution.


Check out the KGFMapSystem,

We have already solved tons of other minimap problems here (4 month of developement + bugfixing + content creation). This unity3d minimap works out of the box, is fully customizeable and if you will need an additional feature just make a feature request at


The standard solution is to set GUIs/miniMaps/etc… once at the start, and then rerun those calculation whenever the window changes size. Actually, the most common fix is just to never let the user change size – run only full-screen. Can you even resize iOS/Android apps?

Some systems provide an OnResize() callback, where you can just paste the “setup GUI coords” code. Unity doesn’t have that (I assume since not all platforms support it?) So you have to check “did the screen size change” yourself (goggle “Unity resize callback.”)