- Home /
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!
Hi Aaron,
Please post a sample of the errors that show in your Console. That will give us a far better idea of what is going on ;)
Please be more specific and post an example (code or screenshots) With the information above you really cant do anything.
Just added pics to it of the errors. Scripts are fine cause I am using them in another project without errors. Same scripts no changes.
Like I said only did this after a clean install of Unity4 after I upgraded the project using Unity4 BETA.
If you need anymore info let me know.
Hmmmm, not sure about this problem. Not encountered it before. I'll have a think though. Anyone else?
Answer by Tricky7991 · Dec 14, 2012 at 03:08 PM
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.
Answer by Nidre · Dec 13, 2012 at 05:29 PM
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.
Thanks for help! But as I mentioned before the code is fine. But since the errors I'm getting do seem like there is a error in the code. I am adding the answer myself now. Thank you again I wasn't sure if this just got forgotten.
I see you are using both JS and C# scripts together.There might be problem with the compile order.As i know you should make sure your Javascript compiles before C#.To be able to reach them from your C# scripts.
$$anonymous$$aybe that order might be causing some of scripts to be detected as problematic.
Ok so Unity has now forgotten how too? Since it worked before I switched from Unity4 Beta to Unity4. If the scripts are the problem(something not coded right) then why do they work in other and new projects fine without any errors?
I'm not telking about how the script has coded.Im talking about compilation order. They might have changed something under the hood and might be affecting compilation order.
And as i said "$$anonymous$$aybe" that might be the reason :)
You might want to check http://answers.unity3d.com/questions/146192/using-c-and-javascript-in-a-project.html this answer if thats the case.
Answer by j-unity · Dec 16, 2012 at 08:39 PM
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.
Answer by signal1101 · Apr 11, 2013 at 10:32 PM
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.
Answer by Gal-la · Jul 25, 2014 at 09:05 AM
you have if empty like if(nam < 10) <-and here is empty if(nam < 10) {
} <- it fix it
Your answer
![](https://koobas.hobune.stream/wayback/20220613084524im_/https://answers.unity.com/themes/thub/images/avi.jpg)