Error with scripts compiling Unity4.

Hey Unity Community! Well I am having problems with Unity 4. I was building this on the last version of Unity3 and all was working good. Got the Unity4 beta backed up my project. Then used Unity4 to upgrade it. And everything worked flawlessly.

So I deleted the old Unity3 project backed up the new one. Today I started Unity and saw that there was a update. So since i still had Unity3 installed along side Unity4. I decided to wipe clean all Unity and Reinstall Unity4 with the new update.

Well after I did that got it installed. Opened my project, and got a error about Namespaces. And on all my prefabs that had scripts, it said that

“The associated script cannot be loaded. Please fix any compiling errors and assign a valid script.”

That is on every script even Unity’s default ones. I’ve rechecked the scripts over and over. And can’t find the problem.

So any help would be good. Thanks in advance! And if this has already been asked I looked but I didn’t see it so a link to the answer would be great!

alt text


There are some methods etc. that have been replaced or removed in Unity 4.Maybe somehow it doesn’t show you those changes as errors/warnings in your code.If you are on Windows you can try to open your solution with Visual Studio and try to build it there(It might fail to build that’s not the point).Visual Studio will check for all syntax errors when you press build.So if there is error in your code somehow it will find for sure.

Well its not the best solution but since there is no accepted answer i think it might worth trying.

If you have this error too after upgrading to Unity4, You will have to make a fresh project. And import all the scripts, models, textures, materials, sounds. And then remake all your prefabs/gameobjects.

Seems like something random that happened switching to Unity4.

EyAaron,…if I´m not wrong Unity4 is really strict reading code as it detects any compilation error al a global fail…so if you have an script wich as an error it probably shows you the messages you added to us. Just try to read in the CONSOLE the script that is giving you an error an try to delete it ( or just maybe select all the code in the script and transform it as a comment ) just to check than when you play then again the messages dissapear…

Let me know if it works for you. If not we´ll try to help you.

I’ve run into this via some source control software that doesn’t resolve metadata and script assemblies. Try doing a quick build of your project for any platform. That should relink your data and get things back to where they should be for you. At least, that’s resolved it in the past for me.

you have if empty like if(nam < 10) <-and here is empty if(nam < 10) {

} ← it fix it