error cs1525: Unexpected symbol `GUI', expecting `(' and error cs8025: Parsing error

so i’m having this problem when i’m creating the main menu for 2D projects, i just want to make a simple one since i’m new to unity and game programming, here’s my C# script
///
/// Main menu
/// Attached to Main Camera
///
using UnityEngine;
using System.Collections;

public class MainMenu : MonoBehaviour {

public Texture backgroundTexture;

void OnGUI(){

//Display our Background Texture
GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), backgroundTexture);
//Display our Buttons

	if GUI.Button (new Rect(Screen.width * .5f , Screen.height * .5f, Screen width * .5f, Screen.height *.1f), "Play Game")){
		print ("Clicked Play Game");
	}
}

}

You have several characters missing:

  • An if statement should start with a colon.
  • You forgot a dot after Screen

This is how your code should look like:

void OnGUI()
    {
        //Display our Background Texture GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), backgroundTexture);
        //Display our Buttons

        if (GUI.Button(new Rect(Screen.width * .5f, Screen.height * .5f, Screen.width * .5f, Screen.height * .1f), "Play Game"))
        {
            print("Clicked Play Game");
        }
    }