Compiler-Errors
Help, my game won’t start!
Unity sais I have to fix all compiler-errors before I can play!
What’s going on? How can I fix this?
Help, my game won’t start!
Unity sais I have to fix all compiler-errors before I can play!
What’s going on? How can I fix this?
Don’t call your script ‘GUI’ or ‘Raycast’. Take a more unique name.
Rather not call your script ‘Hy-phen’, ‘Some.dot’, ‘Under_score’ or ‘1NumberAtTheStart’
javascript-code in a .cs file?
c#-code in a .js file?
Note: don’t worry if you have millions of errors.
The amount of error-messages says little about how good or bad your code is!
often, a single problem makes the compiler throw hundreds of errors because it missreads subsequent lines of code that are actually ok.
once you solve that one issue they may disappear by the dozen.
On the other hand, if only a single error shows up that does not mean there’s little wrong…
That might only be because that error is so bad that it stops the compiler from checking further.
That hides any amount of other errors who will show up as soon as you fix the first one.
leave out this step, if you have runtime-errors!
Sometimes it’s very cryptic or misleading for a beginner but sometimes it acutally tells you straight out what you have to do.
It opens the script and puts the cursor in the line where it gets the error.
(The error-message also tells you which line and position; that looks like so: (13,61), meaning Line 16, position 61)
Note: most of the times this is only a rough estimate of where the problem really is.
‘Compiler-Error’ is more or less a synonym for ‘Syntax-Error’
Compiler is the thing that translates your script into binary-code (the 010101101-stuff) that the computerhardware can work with
Syntax means the Grammar of a Script.
People are smart and usually can figure out the essence of a sentence based on vocabulary.
Computers, by contrast, are stupid. They need you to stick to grammar very strictly to get what you mean.
all the following explanations confuse you only ever more? This might lift some mysteries:
Note: I just collected the information I found on UnityAnswers.
This is probably far from complete!
If you find something wrong or like to add stuff, please do!
Usually you miss a ‘;’ in the respective line,
Or you have a ‘;’ too much in the code above,
Or you missed {} around several stuff in a if-statement or loop
Check the link. SpikeX gives a good list of advice what to try.
You created a completely empty Scriptfile. This error should go away if you write some code or hit ‘clear’ in the console.
you missed or missplaced a ’ } ’
It’s unclear what you are referencing. It’s well explained here:
You are trying to use a variable or function that has not been defined.
Most likely misspelled or forgot to declare ‘X’ properly.
or you did not define the path to ‘X’
http://answers.unity3d.com/questions/31996/unknown-identity-itween.html
A rare Error. Not enough information…
You probably used function X with values of type Z but it only can take values of type Y.
Put your cursor at function X and hit F1 to see the ScriptReference what kind of values Y are possible.
Or if it’s a self-defined function you have to change the possible input-parameters.
This means Unity can’t find a Script with the Name ‘X’.
Likes to happen when you try to make c# and javascript work together.
This error sometimes has to do with variables/functions not being typed/type-casted correctly/at all.
or missing the proper path to a variable
(especially popular: X.position instead of X.transform.position)
most likely you spelled something with a lower-case first letter which should be upper-case.
e.g. gameObject which should be GameObject or particleEmitter which should be ParticleEmitter
This error has something to do with mono-dlls and there are rumors that it appears in connection with unity-bugs.
This probably means you are trying to do an operation in this line that requires type ‘Y’ to work, but your variable has type ‘X’.
This can happen if you did not type your variable (correctly) right at the start.
You may try to cast the type with the as-operator.
You are calling some built-in function with wrong stuff in the ().
Looking in the Scriptreference for ‘X’ tells you what you can use.
(put your cursor at ‘X’ in the code and hit F1 to quick-find it in the Reference)
‘(Y)’ is telling you what you currently are using.
You probably missed ‘()’ when calling a function or a loop or if-statement, e.g.
Application.Quit;
has to be
Application.Quit();
if (a==b){} else if {}
has to be
if (a==b){} else if (c==d){}
This roughly translates to ‘something bad happend somwhere around here’
Sorry… Check the ‘general checklist’.
Sometimes you are actually missing ‘X’ exactly in that place… but often enough it’s something else.
Sorry… Check the ‘general checklist’.
A rare Error. Not enough information…
You may be trying to do (math) stuff with types that don’t match (e.g. multiply a GameObject with a Number)
Or you try to do stuff with an undefined Variable
A rare Error. Not enough information…
This can occure when you use recursion (a function that calls itself)
Such a function has to be typed as IEnumerator or replaced by a while-loop
Unity is trying to treat ‘X’ like a function (probably because you put () after it), but that doesn’t work.
In script ‘X’ you probably have two functions with the name ‘Y’.
Remove or rename on of them.
Pretty self-explaining: The math-stuff you are trying to do can’t be done with something of type Y and of type Z.
e.g. can’t multiply transform.position (a Vector3) with transform.forward (another Vector3).
Maybe you typed one of the variables wrong?
You are trying to do something that can only be done with variables of type ‘Y’ but the variable us use has type ‘X’
This error likes to pop up when you try if(something)
and something is not of type boolean.
Thanks to the error you already know what the type of ‘something’ actually is (e.g. float) so sometimes you can work around with something like if(something != 0.0f)
Quote Peter G: You have multiple classes (scripts) with the same name. Change the name of one of them
Maybe you miss a namespace. (A ‘using System.Something;’ at the beginning of the Script)
Or you did not extend from a proper class (normally ‘MonoBehaviour’)
A rare error. Not really enough information.
A rare error; Probably messed up {}
You are trying to access a Variable or Function ‘Y’ in a Script or built-in class ‘X’ but that class doesn’t have that.
Maybe you named your script like a built-in class?
You probably missed the ‘new’-keyword
A rare Error.
A rare error; a foreach-loop is missdefined. Maybe you want a simple for-loop anyway?
You probably misspelled ‘X’
‘X’ denotes a Script that does not exist/has a different name
A rare Error. You have variables of type ‘X’ but try to do stuff with them that can only be done to variables of type ‘Y’.
But their types are not all that different (e.g. both number-types) and they can be converted. You just need to find out how
Quote Mike 3: Only the C# built-in types (excluding System.Object) may be declared as const.
You may want to look into readonly instead - very similar, but allows writing at construction time
A rare Error.
A rare Warning. Check out the post to get rid of it:
http://answers.unity3d.com/questions/60461/warning-cs0649-field-is-never-assigned-to-and-will.html
A rare error; the only one I found was because of a misspelling…
quite likely you missed a ’ ; ’ in the line above the error.
A rare error. The ones I found were due to misspelling.
This roughly translates to ‘something bad happend somwhere around here’
Sorry… Check the ‘general checklist’.
A rare error. Not enough information…
A rare error. Not enough information…
A rare error. Not enough information…
A problem with your class-definition.
Probably either missed your ()
http://answers.unity3d.com/questions/130009/whats-worng-with-this-please-answer.html
messed up your {}
http://answers.unity3d.com/questions/63129/unable-to-find-solution-for-errors.html
or you missed a ’ ; ’ in the lines above class-definition
http://answers.unity3d.com/questions/45371/what-does-error-mean-i-got-it-from-this-line-of-sc.html
Quote Mike 3: ‘Try using a higher shader profile, e.g. #pragma target 3.0
’
http://answers.unity3d.com/questions/17772/solved-cg-error-profile-does-not-support-for-state.html#
Probably something is wrong with your scale
http://answers.unity3d.com/questions/8276/what-causes-error-sh-maabbisvalid.html
http://answers.unity3d.com/questions/11016/what-does-slot-getlocalaabbisvalid-mean.html
You may have found a c/c++ error of the UnityEngine. Maybe you should file a report.
If you are lucky, it will go away if you restart.
Don’t call your script ‘GUI’ or ‘Raycast’. Take a unique name.
http://answers.unity3d.com/questions/46651/networking-problem-please-help-javascript.html
Rather not call your script ‘Hy-phen’, ‘Some.dot’, ‘Under_score’ or ‘1NumberAtTheStart’
(I’m not sure on the exact rules, but better save than sorry…)
javascript-code in a .cs file?
http://answers.unity3d.com/questions/21592/i-cant-figure-why-im-getting-a-parsing-error-with.html
http://answers.unity3d.com/questions/142523/parsing-error-no-idea-what-it-is-or-what-the-probl.html
c#-code in a .js file?
http://answers.unity3d.com/questions/48992/using-for-in-unity-script-help.html
http://answers.unity3d.com/questions/32814/unexpected-token-collider.html
shader- or any other code in a .cs or .js file?
http://answers.unity3d.com/questions/31856/unlitalpha-shader-script-not-working.html
http://answers.unity3d.com/questions/47286/unitymasterproject.html
These are viciously hard to spot!
http://answers.unity3d.com/questions/149429/script-help.html
http://answers.unity3d.com/questions/148876/uce0001-expected-insert-a-semicolon-at-the-end.html
http://answers.unity3d.com/questions/64770/please-help-me-with-this-boolean.html
especially popular to happen after if(), for() and while().
http://answers.unity3d.com/questions/56926/why-is-this-giving-me-an-error.html
http://answers.unity3d.com/questions/118785/when-i-try-to-run-the-island-demo-on-unity-3-i-get.html
http://answers.unity3d.com/questions/34937/script-wont-run-level-platformer-tutorial.html
http://answers.unity3d.com/questions/46972/scripting-problem-with-if-statements.html
http://answers.unity3d.com/questions/148876/uce0001-expected-insert-a-semicolon-at-the-end.html
http://answers.unity3d.com/questions/43143/help-expecting-found-problem.html
Don’t have a Script ‘DoSomething’ and a Function ‘DoSomething’.
http://answers.unity3d.com/questions/23286/the-best-overload-for-the-method-unityengineobject.html#
function Update() { function MyFunction(){} }
doesn’t work
http://answers.unity3d.com/questions/30200/help-me-debug-this-code.html
http://answers.unity3d.com/questions/34283/could-someone-tell-me-whats-wrong-with-this-script.html
http://answers.unity3d.com/questions/21674/what-is-wrong-with-this-c-code-i-have.html#
http://answers.unity3d.com/questions/57669/error-with-array-declaration.html
http://answers.unity3d.com/questions/125965/correct-script.html
http://answers.unity3d.com/questions/54388/unexpected-token-.html
http://answers.unity3d.com/questions/154072/instantiate-coming-up-with-errors-for-unknown-reas.html
http://answers.unity3d.com/questions/56024/cant-start-must-fix-all-comiling-errors-oxfffd.html
http://answers.unity3d.com/questions/31996/unknown-identity-itween.html
Fixing grammar is always the same, no matter the genre or subject.
e.g. it does not matter if your script is about flying or taking the dog for a walk.
if a ’ ; ’ is missing, a ’ ; ’ is missing.
You can, however, mention what kind of vocabulary is going wrong, e.g. ‘arrays’, ‘for-loop’, ‘hashtable’ etc.
var backgroundStyle : GUIStyle = new GUIStyle() /**** <- ERROR happening HERE ****/
Good hunting!
Greetz, Ky.
Error CS1526 update:
I fixed this by adding a semicolon to the end of the variable declaration located on the line immediately above the line the mono editor said was failing to compile…
Cheers!
GameDaddy
For CS2011: Unable to open response file: ‘X’
Since this is a more ambiguous compile error, I will post my use case.
My use case: when I added a C# script file , I would get a compile error
My fix: I created the project in a public folder instead of a private folder.
basically, it was a permissions issue.