- Home /
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");
}
}
}
Answer by moriam · Apr 19, 2015 at 04:09 PM
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");
}
}
ok, now i get the "error CS0116: A namespace can only contain types and namespace declaration", i dont even know what that exactly means i totally have no idea cause this is my first time using unity and i have just started making games