Can someone Help Me Unexpected Symbol '(' in class, struct ,or interface
So i wrote down this start menu script and it says unexpected symbol '(' and i cant find it can someone please point it out and tell me how to fix it.
using UnityEngine.SceneManagement;
using UnityEngine.UI;// we need this namespace in order to access UI elements within our script
using System.Collections;
public class menuScript : MonoBehaviour
{
public Canvas quitMenu;
public Button startText;
public Button exitText;
void Start()
{
quitMenu = quitMenu.GetComponent<Canvas>();
startText = startText.GetComponent<Button>();
exitText = exitText.GetComponent<Button>();
quitMenu.enabled = false;
}
public void ExitPress() //this function will be used on our Exit button
{
quitMenu.enabled = true; //enable the Quit menu when we click the Exit button
startText.enabled = false; //then disable the Play and Exit buttons so they cannot be clicked
exitText.enabled = false;
}
public void NoPress() //this function will be used for our "NO" button in our Quit Menu
{
quitMenu.enabled = false; //we'll disable the quit menu, meaning it won't be visible anymore
startText.enabled = true; //enable the Play and Exit buttons again so they can be clicked
exitText.enabled = true;
}
public void StartLevel() //this function will be used on our Play button
{
}
public void ExitGame() //This function will be used on our "Yes" button in our Quit menu
{
Application.Quit(); //this will quit our game. Note this will only work after building the game
}
SceneManager.loadScene(1)
}
Ok i fixed but it still says '(' is an error please help @gooopil
Post your updated script and the complete error, no way to help you with that little info.
Assets/$$anonymous$$enu Script.cs(52,27): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
sorry forgot to tag you @gooopil
Assets/$$anonymous$$enu Script.cs(52,27): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
that is the error that is there
O$$anonymous$$ for the error, but do post your code so I don't have to guess!
the code is the one up there in the main post same one didn't do any changes
yeah okay ill get to that lots of thanks for helping you really helped @gooopil
Answer by gooopil · Apr 09, 2016 at 02:49 PM
Your last line of code :
SceneManager.loadScene(1)
Is directly in your class, whereas it should be within a method. It's also lacking a semi-column.
Answer by chaz1186 · Apr 09, 2016 at 04:01 PM
within a method? sorry im new at coding i followed an example so it is hard to understand what exactly you mean @gooopil
For instance:
public void ThisIsA$$anonymous$$ethod()
{
Scene$$anonymous$$anager.loadScene(1);
}
https://en.wikipedia.org/wiki/$$anonymous$$ethod_(computer_program$$anonymous$$g)
I'd avise you to read some generic program$$anonymous$$g tutorials, including Object-oriented program$$anonymous$$g tutorials, that will help you a lot!
Nope, your methods belong within a class, not outside.
Here's a basic explanation of some principles : https://msdn.microsoft.com/en-us/library/dd460654.aspx
Your answer