- Home /
The class defined in script file named 'ConnectGui' does not match the file name! JavaScript
Hi, I have seen similar problems with C# but I'm getting this problem using JavaScript. How do Where is the class definition within the script?
I.E. What is the JS equivilent of //CODE public class NewBehaviourScript : MonoBehaviour { //END CODE
Answer by Mike 3 · Dec 18, 2010 at 08:27 AM
Generally you don't need to declare the class yourself if it's going to be a MonoBehaviour, it's done implicitly, saving you from needing to rename it when you rename the file
if you do, it's
class Name extends MonoBehaviour {
Answer by Ray-Pendergraph · Dec 18, 2010 at 02:11 PM
Unity passes over the project and compiles all of the UnityScript (javascript) scripts into IL classes just like C# classes. The name of the synthetic class in the UnityScript assembly for that pass is the name of the javascript file without the .js. What you are saying makes me think that you perhaps changed the name of the file and Unity got confused or something as there are no explicit class definitions in UnityScript. Technically users of UnityScript should never see this error. Maybe you can try redragging the script reference or something.
Answer by YoshieMaster · Dec 19, 2010 at 05:53 AM
Hey, thanks for the responses but I solved this myself. The problem was that I did a change to my game that broke it, and then I restored only the Assets folder of my backup, not the Library.
Thanks again, hope this helps some other n00b who has the same problem.
So how did you fix your Library folder?
I've made the same mistake, and now Unity is giving me warnings about how the class name doesn't match the script name even though they are identical.
How did you get things back to normal?
Answer by DrieStone · Mar 10, 2013 at 03:07 AM
I'll throw this in here too. I had this error when I mistakenly put an extension on my filename in my project browser. The file on disk was then called [file].js.js which confused Unity.
Your answer
Follow this Question
Related Questions
Creating Custom Script Classes 2 Answers
Putting extra classes into JS script a no no? 1 Answer
Static array with custom class? 1 Answer
help with creating a static Instance in javascript 2 Answers
help me converting js to c# 1 Answer