- Home /
How to set the position of a guitext using transform?
I'm having trouble setting the position of my guitext, I use these ratios for my other gui's but with the guitext it makes the pos x and pos y -.06. I try changing the x and y using this script but it doesn't change the x and y to 0-1 in the inspector. Is there a way to fix this so that I can change the text position with the script?
void Update () {
horizontalRatio = Screen.width / BASE_WIDTH;
verticalRatio = Screen.height / BASE_HEIGHT;
guiText.text = "Score: " + score;
guiText.fontSize = Mathf.Min(BASE_HEIGHT,BASE_WIDTH)/FSize;
transform.position = new Vector2(ScoreX * horizontalRatio,ScoreY * verticalRatio);
}
Comment
@RetepTrun yes but there is an implicit cast between Vector2 and Vector3
$$anonymous$$y guitext isn't parented to a texture, I made it so the gui are all separated
Answer by vptb · May 29, 2014 at 03:34 PM
On the GUIText Transform make it (0,0,0) and then on the script change the guiText.pixelOffset property, where (0,0) is the bottom,left corner.