How to set text(timer) to a fixed place

Hey there :slight_smile: I am working on a project where I include a timer, but it seems that it won’t stay at the same place, dependin on the game’s resolution. I would like to stay on a specific place on the screen, how is it possible? Thanks for you advices.

Here is the timer’s script, along with how I determine its position:

var startTimer: int;
var minutes : int;
var seconds : int;
var style : GUIStyle;

function Start() {
    startTimer = Time.time;
}
 
function Update() {
    var time = Time.time - startTimer;
    minutes = time / 60;
    seconds = time % 60;
}
 
function OnGUI() {
    GUI.Label (Rect (850, 800, 200, 20), String.Format ("{0:0}:{1:00}", minutes, seconds), style);
}

You will need to calculate the position relative to the resolution. Screen.width and Screen.height gives you the size of your screen. eg if you want to place it at the centre top side of the screen you could try Screen.Width / 2. If you want it on the bottom right corner try to put the start point 200 pixels from the right side:

e.g.

function OnGUI()
{
     GUI.Label (Rect (Screen.width - 200, Screen.height - 20, 200, 20), String.Format ("{0:0}:{1:00}", minutes, seconds), style);
}

(example is untested. I am on a computer without unity right now)

Play a bit around with the values in Rect. I am sure you will find a good position.