- Home /
expecting EOF, found 'showOptions'
(sorry if this is a stupid question, I'm new) What does it mean when I get a EOF? How do I fix it? #pragma strict
showOptions : boolean = false;
function OnGUI () {
if (GUI.Button (Rect (10,500,150,70), "Multiplayer")) {
Application.LoadLevel(1);
}
if (GUI.Button (Rect (10,610,150,70), "Quit")) {
Application.Quit();
}
if (GUI.Button (Rect (10,720,150,70), "Options")) {
if (showOptions = false) {
showOptions = true;
}
if (showOptions = true) {
showOptions = false;
}
}
if (showOptions = true){
//START THE OPTIONS PAGE
GUI.Box (Rect (100,10,200,1000), "Graphics Resolution");
if (GUI.Button (Rect (100,40,80,20), "Fastest")) {
QualitySettings.currentLevel = QualityLevel.Fastest;
}
if (GUI.Button (Rect (100,70,80,20), "Fast")) {
QualitySettings.currentLevel = QualityLevel.Fast;
}
if (GUI.Button (Rect (100,100,80,20), "Simple")) {
QualitySettings.currentLevel = QualityLevel.Simple;
}
if (GUI.Button (Rect (100,130,80,20), "Good")) {
QualitySettings.currentLevel = QualityLevel.Good;
}
if (GUI.Button (Rect (100,160,80,20), "Beautiful")) {
QualitySettings.currentLevel = QualityLevel.Beautiful;
}
if (GUI.Button (Rect (100,190,80,20), "Fantastic")) {
QualitySettings.currentLevel = QualityLevel.Fantastic;
}
}
}
When it says it wants EOF, it means it doesn't want anything there. So Unity is saying showOptions (on whatever line it says you have it on) should not be there. Forgot a semi-colon or a curly bracket maybe?
You will do yourself a huge favor if you format code properly with consistent indentation, so you can easily catch extra (or missing) bracket errors.
Answer by clunk47 · Dec 03, 2012 at 02:07 AM
There are a couple problems here. EOF means "End Of File". Not sure why it was looking for end of file, but what solves this... Instead of
showOptions : boolean = false;
you need to declare that this is a variable, or var. so you would type :
var showOptions : boolean = false;
Another thing wrong with your script, you have IF statements with the wrong "=" sign. When you want to declare something is true or false, you do this = true, or that = false. But if you want to find out if something is equal to something, you use ==, a double equal sign which means "is equal to." so instead of
if(showOptions = true)
you would want
if(showOptions == true)
you could also use
if(showOptions)
or if not equal, you could use a "!" exclamation point in front for "not" like so:
if(!showOptions)
so if(showOptions) is equivalent to if(showOptions == true), or if(showOptions.Equals(true))
and vice versa. if(!showOptions) is equivalent to if(showOptions == false) or if(showOptions.Equals(false))
here is your script with these fixes.
#pragma strict
var showOptions : boolean = false;
function OnGUI ()
{
if (GUI.Button (Rect (10,500,150,70), "Multiplayer"))
{
Application.LoadLevel(1);
}
if (GUI.Button (Rect (10,610,150,70), "Quit"))
{
Application.Quit();
}
if (GUI.Button (Rect (10,720,150,70), "Options"))
{
if (!showOptions)
{
showOptions = true;
}
else if (showOptions)
{
showOptions = false;
}
}
if (showOptions)
{
//START THE OPTIONS PAGE
GUI.Box (Rect (100,10,200,1000), "Graphics Resolution");
if (GUI.Button (Rect (100,40,80,20), "Fastest"))
{
QualitySettings.currentLevel = QualityLevel.Fastest;
}
if (GUI.Button (Rect (100,70,80,20), "Fast"))
{
QualitySettings.currentLevel = QualityLevel.Fast;
}
if (GUI.Button (Rect (100,100,80,20), "Simple"))
{
QualitySettings.currentLevel = QualityLevel.Simple;
}
if (GUI.Button (Rect (100,130,80,20), "Good"))
{
QualitySettings.currentLevel = QualityLevel.Good;
}
if (GUI.Button (Rect (100,160,80,20), "Beautiful"))
{
QualitySettings.currentLevel = QualityLevel.Beautiful;
}
if (GUI.Button (Rect (100,190,80,20), "Fantastic"))
{
QualitySettings.currentLevel = QualityLevel.Fantastic;
}
}
}