Script changes don't compile

Whenever I edit and save a script and go back to Unity it starts compiling. But it still uses the older unedited version of the script. Even if I add some public members to MonoBehaviour they won’t appear until I either close and open unity again or reimport the script. This started to happen in Unity 2017 and I had no problems like this in previous versions.

It’s getting quite frustrating spending time on recompiling each script two or three times just for the changes to take effect.

Please help.

5 Likes

I’m experiencing the same issue in 2017.1.0f3
I edit the script in VS 2017. When I switch back to Unity I can see the indicator working, but when I run, Unity uses the old version.

Changing the file a couple more times then results the script finally updating.
Reimporting the script manually using the context menu also fixes the script.

EDIT: Manually reimporting the script doesn’t always help!

I have the same problem since update to 2017.
when edit my script in VS and save, unity execute the script without changes applied. Then, back to script, and edit whit some space lines (enter) anywhere on the script, save again and then finally update script, but not ever.
Its a big problem because you cant know if your test code its working if you dont know if script is updated :frowning:
Sorry for my bad english. Any solution?

Is a project using unity collaborate, im owner, can be affect the problem ?

Same here :frowning:

I was (possibly still am) having this same issue with:

  • Windows-x64 version of Unity 2017.1.03f_Personal
  • Microsoft Visual Studio Community 2017, 15.2_Release
  • Visual Studio Tools for Unity, 3.1.0.0

I upgraded to Unity/VS 2017 without doing a clean install, so I still had Visual Studio 2015 on my system. Closing out of Unity/VS 2017 and uninstalling VS 2015 seems to have helped, though the issue was so intermittent that I’m still testing to see if it really worked.

@unidad2pete : I was having the issue across multiple new projects, none of which were using Collaborate/Team tools.

Edit: I have not had this issue since uninstalling Visual Studio Community 2015.
Edit 2: Still having this intermittent issue after all and am trying a clean install. When it strikes, I can highlight the affected script and see my changes in the inspector, but for whatever reason Unity still uses the older compile. Re-importing the script will often do nothing. Closing Visual Studio before re-importing seems to help but I can’t be certain.

Ok, maybe we have a solution, I found this on note paths of next unity version:

Fixes

  • Graphics: Fixed memory leak in Texture2DArray and CubeMapArrayTexture. (919162, 930677)
  • Scripting Upgrade: Fixed an issue where assemblies built with .NET 4.6 fail to load. (922577)
  • Video: Fixed audio playback when AudioSource is disabled in VideoPlayer. (907755)
  • Video: Fixed performance issues with VideoPlayer creation/destruction. (888745)

its a know issue fixed on beta version and next update:

Im installing beta version, and post if fix problem on few minutes

No way :frowning: the problem continues on beta version.
Im so frustrated, I reinstalled, VS, unity, updating all windows updates, and try to new version, but problem not fixed.
I cant work with this problem.

Editing files directly with other editor like notepad++ works perfect. The problem its related with Visual Studio.

I uninstalled MySQL for VisualStudio, problem seems be fixed now.
I dont know if that was the problem, but now works fine.

I am having the same problem in 2017.1.0f3.

Restarting Unity doesn’t always correct it, restarting Visual Studio (community 2017) doesn’t always correct it. Sometimes, even making further changes to the script and recompiling doesn’t even fix it.

It’s quite frustrating :frowning:

I started experiencing the same issue the moment I upgraded Unity from 5.6 to 2017.1.0f3 (never before that). I’m using Visual Studio CE 2013. Uninstalling Visual Studio CE 2015 didn’t help me.

This is really problematic, since you can’t be sure if the code you are running is actually the latest version.

Same problem with 2017p2 and VS2017.

I started putting in debug.log statements that would show up so I knew the changes I make were actually running… this is crazy

This issue came up for me a few days ago mid-development. I have no clue what triggered it. This is my configuration:

  • Unity 2017.1.0f3
  • Visual Studio 2017 Enterprise, Version 15.2 (26430.16) Release
  • .NET 4.6
  • Visual Studio Tools for Unity 3.1.0.0

One possible workaround is to delete the folder Library/ScriptAssemblies in from your project. This will definitely force a recompilation.

We have been trying to reproduce the issue with no success for far

If you have a project in which this reproduces consistently (this raises the chances of getting this fixed quickly) can you share with us? (preferably filling an issue) .

When this happens, it would be interesting to check whether the actual assembly (Library/ScriptAssemblies/Assembly-CSharp*.dll) gets updated or not (you can verify this through ILSpy, dotPeek, ildasm, etc.)

Best

Adriano

2 Likes

I got this issue , Only way to fix was to install new windows on new disk partition, all works fine until now, i dont know why, but I have the bug again, I removed Library/ScriptAssemblies and now seems to be fine, but im sure the bug return on any moment. I need to fix, how i can help you? you need the full project? we can get a direct chat with teamviewer and give you control of my Pc if you need see anything, you can send me e-mail to contact I help all you need if fix the problem.

I have this issue as well. It is extremely frustrating to be outputting debug messages all the time to see if your new code is actually running. It has gotten even worse these days, I have to recompile the scripts 3 or 4 times all the time.

  • Unity 2017.1.0f3

  • Visual Studio 2017 Community, Version 15.2 (26430.16) Release

  • Windows 10 pro

  • i7-6700HQ

I think I found a klutzy way around it for now… but it’s a pain.

If I force an error in my code (leave off a semicolon at the end of a line), let Unity complain about the error, then put the semicolon back, it seems to always see my code changes then.

edit never mind… I tried it 10 times and it worked every time. I post here, and then it stops working LOL

I have the same issue in Unity 2017.1.0f3. Never had this issue in previous versions. What I have to do is to select the folder where my scripts reside and then click “Reimport”. Very frustrating. Deleting "Library/ScriptAssemblies" did not fix the problem.

Deleting "Library/ScriptAssemblies" works for me, and I can confirm, the actual assembly (Library/ScriptAssemblies/Assembly-CSharp*.dll) not get updated. Checked with dotPeek
And the problem occurs for me ( not ever ) when I open new Unity instance with other proyect.