- Home /
Change scripted gui text postion
I have a script that displays gui text on the screen but it is set to default as the top left corner of the screen. I am a bit of a scripting noob but how do i change the position to somewhere else (eg the top middle of the screen.)
Here is the script:
function OnGUI()
{
GUILayout.Label( "Score = " + score );
}
(I have cut out the top part of the script)
Reference for GUI https://docs.unity3d.com/Documentation/ScriptReference/GUI.html Reference for GUI.Label https://docs.unity3d.com/Documentation/ScriptReference/GUI.Label.html also you are missing the Rectangle to give it its position try GUILayout.Label(new Rect(100,100,100,20), "Score = " + score );, where new Rect(leftpos, toppos,width, height)
Your answer
Follow this Question
Related Questions
Change GUI button position in code 1 Answer
Dynamically changing a decals position on a mesh surface 2 Answers
changing pivot's placement 2 Answers
Changing distance with Vector3.Distance 1 Answer
transform.position not moving object 2 Answers