GUI button creation and placement

Hi everyone!

I’ m an absolute beginner to Unity and scripting. I’ ve been following along to a tutorial book for Javascript and am at the GUI button portion. I follow the code example exactly but am having issues with the placement of my GUI button. I am trying to place the button in the centre of my screen, but when I push play to test the button appears lower left centre area of my screen I’ve taken a screen shot to demonstrate. I’ve looked for answers through google but have not find a solution to my problem. I even looked at the scripting reference but do not believe I found anything there to help me.

Here is the code for it.

![function Start () {


	function OnGUI() {
var customSkin : GUISkin;
//button width
var buttonW : int = 100;
//button height
var buttonH : int = 50;
var halfScreenW : float = Screen.width /2; //half the screen width
var halfButtonW : float = Screen.height /2; //half the button width = customSkin;
		if (GUI.Button(Rect(halfScreenW - halfButtonW, 560, buttonW, buttonH),"Play Game"))
			Debug.Log("Clicked the button with text");

Its because you are setting your button to the position:

Rect(half - half, 560, 100, 50)

You need to do this:

GUI.Button(Rect(Screen.width/2, Screen.height/2, buttonW, buttonH), "Play Game!");


halfScreenH = Screen.height/2;
GUI.Button(Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Play Game!");

Hope i helped ya!