# All scripts in Unity game can not be loaded

I can not provide a "why" here, because as far as I can tell it happened spontaneously - after saving an edit to one of my scripts, it just started happening. But here's the problem:

Every single one of my scripts, while still in the same Scripts file, can no longer be found and loaded. All the Script Components (take the Game Manager component for example) now look like this:

or like this:

Attempting to locate the scripts by going Add Component > Scripts > [Desired Script] doesn't work, because there isn't even a Scripts item in the Add Component menu. I have already looked this up, and none of the answers I found were applicable:

• Yes, every script's file name is the same as the Class name within them
• I have tried reimporting all assets (Assets > Reimport All), no success.
• Taking all scripts out of the project, restarting unity and then reimporting the scripts. Nothing
• Removing all script components, then reapplying them. It didn't work because, as I said, there was no Script item in the Components menu.

This is a pretty game-breaking, literally, because this is a hobby game (I'm not doing this as a job, it's just in spare time). If I can't restore the game as it was, I won't be able to bring myself to restart it. So any help is greatly appreciated.

• The error is indicating that the compiler is unable to compile your scripts because of errors. Build the project in visual studio, or monodevelop, or whatever IDE you are using, and fix any compile time errors you encounter. Apr 6 '17 at 9:52
• I should've included this; Monodevelop shows no errors at all when I compiled from it. Unity itself only lists one error, apparently a parsing error on line 19 of a certain script. I checked it out, and there's no problem with it, or any of the other scripts - which were working just fine until this problem cropped up Apr 6 '17 at 10:43
• "parsing error on line 19" and "there's no problem with it" are not compatible statements. If the compiler won't compile it, then there's a problem with it — whether or not we agree the compiler "should" compile it, code that doesn't compile in reality is a problem. Show the trouble code if you need help debugging it. Apr 6 '17 at 12:24
• @DMGregory I opened up the problem file, about to copy in the code which the compiler said was problematic, when, after 5 hours of fruitless debugging, a window popped up at the bottom: Convert to Unix Line Endings?. So, I have no idea why, but apparently it got corrupted somehow. I was right, the code was not buggy. But I don't know exactly what I did wrong, so I'm not sure what to post as my 'solution'. Any ideas? Apr 6 '17 at 13:25
• "Ensure all of your script files are using line endings consistent with your development system" would work. Apr 6 '17 at 13:30

## What to do:

Essentially, the answer is to make sure all script files have line endings consistent with your development system. If you don't know how to do that, this is what I did (albeit accidentally, at first):

1. On Monodevelop, save each open file, close each one, then finally close Monodevelop itself.
2. In Unity, there should be a parsing error message. Double click the error message to reopen Monodevelop and open the problem file. Now, at the bottom of the page, a message should pop up:

1. Hit OK. Nothing will visibly change on the page.
2. Go back to Unity, the parsing error message should clear. However, some Script Components will have lost their Script references. These will show up in warning messages when you attempt to play (most likely alongside actual errors stemming from the lost scripts. Just go to each of the listed GameObjects and reattach the appropriate script. It should now be back to normal, with no painful side effects

• Note: If multiple files have messed up line endings, you will have to repeat this process for all the corrupted scripts. This problem can also occur to Shaders, which are slightly harder to detect.
• Note 2: Remember to check the script references on your prefabs, or anything that isn't in the scene right when you hit play. For example, laser bolts, bullets and arrows

## Why It Happens:

This, I'm less sure of. If I can find out why, I'll edit this to include why. If anyone knows why or has a suggestion, comment it. I didn't do anything abnormal when it happened to me.