Changes to code have no effect in Unity.

I’ve been working on a class group project in Unity and I keep losing a lot of time because of a strange case I’ve been experiencing when writing my code. For some reason, I can make changes to my code, but they don’t seem to affect the games behavior while in the editor and I cannot figure out why. The only thing that I have seen that fixes it, is waiting for the code to take affect and for the problem to fix on its own. I’m not going to share any examples of the code right now, because I’m certain it’s not the codes problem.

Here is an example of the behavior, I was working from a tutorial on a script, studying how to generate meshes in Unity. I had one section of the code and ran it fine. I added another, and it was still acting just as before. All that fixed it was waiting. I don’t know why.

Currently, it’s telling me that a null object is being referenced in a comment line. And I don’t think that’s even possible.

I’ve asked other members of my team if they’ve experienced this problem, they haven’t. And I’ve had a hard time finding anyone that has had a similar problem with the engine.

I haven’t experienced your problem and i work with Unity on a daily basis for years now.

If you change something in the code, and save those changes, you will see a circular icon in the bottom right corner of the Unity window. Note that the Unity window needs to be in focus to process your changes.

Some wild ideas:

  • Are you working on the windows drive? Do you have permission to change files?
  • Do you leave playmode? It’s neccessary to restart playmode in order to see changes.
  • Are you using MonoDevelop? If so, get Visual Studio.

I think you have found the solution you need but wanted to mention: you can force unity to immediately recompile a script by right-clicking the script in the unity project window, and selecting reimport. Select Reimport ALL, to recompile all scripts immidiately (though this does other stuff too…).

If your project takes too long to compile in general, consider breaking it up: Perhaps you can put some of the code, that is “finished” into a separate DLL. That way, it won’t have to be recompiled each time.