- Home /
Question by
Daniel 8 · Jun 27, 2010 at 10:00 AM ·
errorscriptdoesntmatchclass
C# Help, Script file name does not match the name of the class defined in script?
Can someone help me with this error, my script doesn't work with this error!
Comment
Best Answer
Answer by andrew · Jun 27, 2010 at 10:15 AM
hi,
you just need to change the class declaration line in the c# script to match the name of the file name of the script. (the class name and file name must match)
if you used unity to create the c# script it will have this line:
public class NewBehaviourScript : MonoBehaviour {
you need to change it using the file name. if this is MyScript.cs then the line should read:
public class MyScript : MonoBehaviour {
@andrew, I changed the formatting of your code. Just FYI, there's a code formatting button on top of the Answer editing window, looks like a "1010101". It's better than using HT$$anonymous$$L, and highlights the code.