I’ve run into a strange script problem. Recently the script compilation in Unity has started acting strangely. After making a change to any of my scripts, Unity compiles the scripts as usual with no warning or errors and all appears fine, however the change I made is not taking effect, as though Unity is still using the old version.
A simple test is commenting out a Debug.Log statement, but it’s still appearing after saving and compiling the script and entering play mode. I am absolutely certain of the change I made and what I am seeing is not correct. If I quit and restart Unity then the script updates to the latest changes. It’s pretty frustrating because now I have to quit Unity every time I make changes to my scripts.
Anyone know what could be causing this?
All my scripts are in C#. Using Unity Pro 4.3.4f1. It maybe related that I recently started working with a precompiled DLL, however the scripts in question are not related to that DLL.
I expect this isn’t happening to the original asker, but for absolute novices coming here: check to make sure you don’t have the script open anywhere else (e.g., you’ve accidentally opened it twice in two instances of your IDE). I’m a decent scientific programmer but totally new to unity and I’ve fallen for this silly beginner’s mistake before.
Oddly, this problem has resolved itself and I’m not sure how. I suspected the precompiled DLL may have been affecting the way Unity was compiling, so I removed it and all was working fine. After a day or so working like that, I have updated and reintegrated the DLL and am not having any issues updating the regular scripts. I do believe there is a bug somewhere in Unity, but it is obscure and not showing up again.
I’m a beginner at Unity and I was having the same issue but I found a fix
After editing a script in Monodevelop and saving go back and left click on the script in Unity. Look at the code in the inspector, if your changes were not applied then right click on the script and select the last option “Synch MonoDevelop Project”. This should update the script and it should execute properly when you test it.
I don’t know how to make Unity auto update on it’s own but this at least has been a manual fix for the problem for me.
I know this is an old thread but what I’m doing is Right Clicking the component → Remove Component → Add it again. Works for me, hope this helps if some newbie got here. Make sure you do this after compile.