- Home /
Can't add script (Doesn't exist?)
So I've been working on the unity scripting tutorials, trying to learn, and now I'm getting incredibly angry at this issue. I started working on the "Enabling Components" part of the tutorial. Commented everything out, made some new voids, and input the code exactly as I was told.
Now all of the sudden my scripts don't exist. I tried deleting the script and pasting the info in a new script.I tried cleaning the build, then rebuilding it. I tried making an ENTIRELY new project with new scripts. And that worked for all of 30 seconds, then it crapped out again.
I see the script, it's there, there are no issues. Why can I not attach it to anything.
Answer by tanoshimi · Sep 23, 2014 at 09:26 PM
Your file is called NewBehaviorScript.cs
but the class you've defined inside it is called Unity
. Classes must match their filename. Also, it's a really bad idea to call a class Unity
, since that's the namespace used for all the built in API classes anyway.
So, right-click to create a new script. The default name should be NewBehaviorScript, but you can change it if you like. If you change it during creation, the class template inside will automatically be changed to match the filename. If you change it at a later time, be sure to update both the class definition and the filename.
Wait, really? So how does anyone make multiple classes then? I never knew this. Thank you for your help. Like a lot. I was losing my $$anonymous$$d.
Just thought I'd add the other cause of this issue - check the console to see if there are any compile errors. If there are you won't be able to add any scripts until these are resolved.
Answer by drudiverse · Aug 22, 2015 at 02:14 PM
I am having this problem when i "create js" called newbehaviour script (empty start and update functions)... and i copy it to an object... sry script doesnt exist.
so somewhere unity has become deeply humorous in a satanic dimension and it is trhsting errors in by botty.
Your answer
![](https://koobas.hobune.stream/wayback/20220613163637im_/https://answers.unity.com/themes/thub/images/avi.jpg)