Search Unity

Script changes don't compile

Discussion in 'Editor & General Support' started by justforunity, Aug 2, 2017.

  1. justforunity

    justforunity

    Joined:
    Dec 21, 2013
    Posts:
    1
    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.
     
  2. mbeast

    mbeast

    Joined:
    Nov 15, 2014
    Posts:
    1
    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!
     
    Last edited: Aug 3, 2017
  3. unidad2pete

    unidad2pete

    Joined:
    Feb 17, 2017
    Posts:
    22
    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 :(
    Sorry for my bad english. Any solution?

    Is a project using unity collaborate, im owner, can be affect the problem ?
     
    Last edited: Aug 3, 2017
  4. HIST0R

    HIST0R

    Joined:
    Sep 21, 2015
    Posts:
    1
    Same here :(
     
  5. BoarFrog

    BoarFrog

    Joined:
    Apr 26, 2014
    Posts:
    4
    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.
     
    Last edited: Aug 8, 2017
  6. unidad2pete

    unidad2pete

    Joined:
    Feb 17, 2017
    Posts:
    22
    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:

    https://issuetracker.unity3d.com/is...55.246771266.1501717651-1951818335.1495257000

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

    unidad2pete

    Joined:
    Feb 17, 2017
    Posts:
    22
    No way :( 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.

     
  8. unidad2pete

    unidad2pete

    Joined:
    Feb 17, 2017
    Posts:
    22
    Editing files directly with other editor like notepad++ works perfect. The problem its related with Visual Studio.
     
  9. unidad2pete

    unidad2pete

    Joined:
    Feb 17, 2017
    Posts:
    22
    I uninstalled MySQL for VisualStudio, problem seems be fixed now.
    I dont know if that was the problem, but now works fine.
     
  10. OldRod

    OldRod

    Joined:
    Mar 2, 2009
    Posts:
    118
    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 :(
     
  11. koplavilppu

    koplavilppu

    Joined:
    Feb 19, 2015
    Posts:
    3
    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.
     
  12. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    228
    Same problem with 2017p2 and VS2017.
     
  13. OldRod

    OldRod

    Joined:
    Mar 2, 2009
    Posts:
    118
    I started putting in debug.log statements that would show up so I knew the changes I make were actually running... this is crazy
     
  14. bnmn

    bnmn

    Joined:
    Jul 30, 2017
    Posts:
    1
    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
     
  15. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    222
    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
     
  16. unidad2pete

    unidad2pete

    Joined:
    Feb 17, 2017
    Posts:
    22
    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.
     
  17. Sytto

    Sytto

    Joined:
    Jul 20, 2010
    Posts:
    28
    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
     
  18. OldRod

    OldRod

    Joined:
    Mar 2, 2009
    Posts:
    118
    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
     
    Last edited: Aug 12, 2017
  19. KrzysztofSikora

    KrzysztofSikora

    Joined:
    Jun 25, 2017
    Posts:
    3
    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.
     
  20. unidad2pete

    unidad2pete

    Joined:
    Feb 17, 2017
    Posts:
    22
    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.
     
  21. OldRod

    OldRod

    Joined:
    Mar 2, 2009
    Posts:
    118
    Deleting the ScriptAssemblies seems to work for me as well.
     
  22. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    580
    I'm having the same problem, thanks unidad2pete for redirecting me here (I posted on the answer forum: http://answers.unity3d.com/question...d-by.html?childToView=1393372#comment-1393372).

    I also had made a post about this in 2016: http://answers.unity3d.com/questions/1287575/saving-project-in-vs-does-not-always-update-unity.html So this problem is not new for me.

    Maybe it's occuring more often recently, anyway it's gotten to a point where it's unbearable.
    It's impossible to work quickly with this. I uninstalled VS2015 and switched to VS2017 the problem is still there.

    It's hard to test the problem because it's almost random. And typing Debug.Log("1") to Debug.Log("20") in the Start() method of a new project until it starts not updating anymore is starting to get on my nerves.

    I do not have the same problem with MonoDevelop, it's a Visual Studio - Unity issue.
     
    Last edited: Aug 14, 2017
  23. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    Hi

    Could you check if "Auto-Refresh" is enabled in "Unity Preferences" / "General" ? I've seen a few reports of this setting somehow being disabled automatically.
     
    angelm_unity, fanged and josefgrunig like this.
  24. KrzysztofSikora

    KrzysztofSikora

    Joined:
    Jun 25, 2017
    Posts:
    3
    "Auto-refresh" was/is enabled in my case.
     
  25. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    580
    It's enabled for me too
     
  26. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    The next step in figuring out what is going is to look at what is written to the Editor.log.

    What should be written when modifying a script something like this:

    Updating Assets/Test.cs - GUID: 97a251c610b234069884001b95e27fb6...
    ----- Compute hash for Assets/Test.cs.
    done. [Time: 95.932714 ms]
    Refreshing native plugins compatible for Editor in 2.08 ms, found 4 plugins.
    Preloading 2 native plugins for Editor in 1.61 ms.

    ----- Total AssetImport time: 0.261855s, AssetImport time: 0.214491s, Asset hashing: 0.000143s [0.5 KB, 3.481681 mb/s]

    - Starting compile Library/ScriptAssemblies/Assembly-CSharp.dll
    - Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll
    The above log statements show that a change to a script file has been detected and that the script is being recompiled.

    If you could share what is written to your Editor.log on script change, then we could possibly get closer to figuring out what is causing this issue.
     
  27. KrzysztofSikora

    KrzysztofSikora

    Joined:
    Jun 25, 2017
    Posts:
    3
    I will try to capture the moment in Editor.log when the script is not refreshed. In the meantime I found this.
    I am using Visual Studio 2017 Community and it is located here: c:/program files (x86)/microsoft visual studio/2017/community/common7/ide/devenv.exe

    EditorHelper: Attempting to use Visual Studio.
    EditorHelper: Looking for a running Visual Studio session.
    EditorHelper: Checking for Visual Studio installations.
    EditorHelper: Searching for Visual Studio 2008 installation using the VS90COMNTOOLS environment variable.
    EditorHelper: No Visual Studio 2008 installation found, trying with the registry.
    EditorHelper: No Visual Studio 2008 installation found at all
    EditorHelper: Searching for Visual Studio 2010 installation using the VS100COMNTOOLS environment variable.
    EditorHelper: No Visual Studio 2010 installation found, trying with the registry.
    EditorHelper: No Visual Studio 2010 installation found at all
    EditorHelper: Searching for Visual Studio 2012 installation using the VS110COMNTOOLS environment variable.
    EditorHelper: No Visual Studio 2012 installation found, trying with the registry.
    EditorHelper: No Visual Studio 2012 installation found at all
    EditorHelper: Searching for Visual Studio 2013 installation using the VS120COMNTOOLS environment variable.
    EditorHelper: No Visual Studio 2013 installation found, trying with the registry.
    EditorHelper: No Visual Studio 2013 installation found at all
    EditorHelper: Searching for Visual Studio 2015 installation using the VS140COMNTOOLS environment variable.
    EditorHelper: Found a Visual Studio 2015 installation here: c:/program files (x86)/microsoft visual studio 14.0/common7/
    EditorHelper: Searching for Visual Studio 15 installation using the VS150COMNTOOLS environment variable.
    EditorHelper: No Visual Studio 15 installation found, trying with the registry.
    EditorHelper: No Visual Studio 15 installation found at all
    EditorHelper: Your preferences indicate Visual Studio should be found here: c:/program files (x86)/microsoft visual studio/2017/community/common7/ide/devenv.exe
    EditorHelper: We did not find a matching Visual Studio installation. We will look for a default Visual Studio installation.
    EditorHelper: We found for a running Visual Studio session with the solution open.
    EditorHelper: We're not sure which version of Visual Studio was requested in the user preferences. We will use this running session.
    EditorHelper: Using the existing Visual Studio session.
    EditorHelper: Getting operations API from the Visual Studio session.
     
  28. MatrixBai

    MatrixBai

    Joined:
    Mar 19, 2012
    Posts:
    13
    Same here after upgrade to 2017.1.0f3. My solution is manually Reimport the script files changed. Hope this bug can be fixed very soon.
     
  29. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    553
    Still getting the issue. I think it might be based on the computer? It happens on every project I create.
     
  30. xbelanch

    xbelanch

    Joined:
    Jul 29, 2017
    Posts:
    1
    One workaround I found if it helps: I set Sublime Text (or another editor I guess) as default. Open it first (and don't close) and then open Visual Studio to continue editing. It works perfectly for me.

    PS: Well actually It doesn't work at all :(
     
    Last edited: Aug 22, 2017
  31. SmShadows

    SmShadows

    Joined:
    Jul 14, 2016
    Posts:
    4
    It happens to us since we updated to Unity 2017.1 and VS 2017 on Windows 7.

    EVERYONE is experiencing this issue at work.

    At some point, Unity stop updating scripts for no reasons and we need to delete the "Library" folder to fix it, but the problem comes back randomly.
     
    Last edited: Aug 22, 2017
  32. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    We have one bug report on this issue where the user investigated further. He is saying he is only experiencing this issue on Windows 7 when ReSharper is installed and the issue went away when he uninstalled ReSharper and he does not experience the issue on Windows 10 with ReSharper installed. He is using ReSharper Ultimate 2017.1.3.

    One thing worth checking besides the Editor.log as I described above, is to check whether the Temp/ folder in the project contains assemblies when the updating of scrips fails. We compile the scripts to that folder first and them copy them to Library/ScriptAssemblies. It might be this copying from the Temp/ to Library/ScriptAssemblies that fails.
     
    Last edited: Aug 23, 2017
  33. MatrixBai

    MatrixBai

    Joined:
    Mar 19, 2012
    Posts:
    13
    I'm using ReShaper 2017.1.3 too, it didn't resolve this issue.
    Yes, you're right, the files in Library/ScriptAssemblies didn't update automatically lead this issue, but don't know how to fix it except reimporting scripts to force Unity recompiling again.
     
  34. BoarFrog

    BoarFrog

    Joined:
    Apr 26, 2014
    Posts:
    4
    When a script fails to update, I get both Assembly-CSharp.dll and Assembly-CSharp.dll.mdb in my /Temp/ folder. When the issue stops and I get a successful update both files are removed.

    I am not using ReShaper or any other extension that was not included in the default installation of Visual Studio from the Unity Installer.

    Edit: This is happening consistently so far, so I can at least monitor if a script update failed by having the /Temp/ folder open on my second monitor. I also can consistently get an update to succeed if I close Visual Studio before reimporting the affected script(s), while reimporting with Visual Studio open usually fails.
     
    Last edited: Aug 23, 2017
  35. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    580
    It's not related to ReSharper for me either, I tried both VS2015 and VS2017 vanilla versions and with ReSharper, it's all the same.
     
  36. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    Based upon the responses here I've attempted a blind fix for this issue.

    You can try the fix by downloading a modified UnityEditor.dll for Unity 2017.1.0f3 from here:

    http://files.unity3d.com/lukasz/share/UnityEditorDLL-2017.1.0f3-ScriptCompileChange.zip

    How to use it:
    - Shut down any running instance of Unity 2017.1.0f3
    - In your Unity 2017.1.0f3 install folder there is a Managed folder with UnityEditor.dll and UnityEditor.dll.mdb
    - Make a backup copy of UnityEditor.dll and UnityEditor.dll.mdb from the Managed folder.
    - Copy the UnityEditor.dll and UnityEditor.dll.mdb from the zip file above into the Managed folder, replacing the original files.
    - Test script compile in Unity 2017.1.0f3 to see if this blind fix changes anything.

    How to revert back:
    - Copy your backups of UnityEditor.dll and UnityEditor.dll.mdb back into the Managed folder of your Unity 2017.1.0f3 install.
     
    Krazyxx, Colorwen, mouurusai and 2 others like this.
  37. syslord2k2

    syslord2k2

    Joined:
    Apr 12, 2011
    Posts:
    23
    Lukasz, i tried your dll files and it updated 20 changes in a row, that never happened before since 2017.1. I will keep using it and report back if it breaks again but for now it seems to be fixed.
     
    Last edited: Aug 24, 2017
    lukaszunity likes this.
  38. Dane-Edwards

    Dane-Edwards

    Joined:
    Feb 13, 2017
    Posts:
    1
    We have been using the fix @lukaszunity provided and haven't had problems since. I'll update this later today if we have the issue again later, but it looks like this fix did the trick.
     
  39. OldRod

    OldRod

    Joined:
    Mar 2, 2009
    Posts:
    118
    Will this patch also work with 2017.1.0p4?
     
  40. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    No. These .dlls are only work with Unity 2017.1.0f3
     
  41. koplavilppu

    koplavilppu

    Joined:
    Feb 19, 2015
    Posts:
    3
    The patch seems to have fixed the problem for me! Thanks!
     
  42. wprevett

    wprevett

    Joined:
    Aug 12, 2017
    Posts:
    9
    I have this problem using 2017.02.0b8 :(
     
    Last edited: Aug 25, 2017
    dCalle likes this.
  43. BoarFrog

    BoarFrog

    Joined:
    Apr 26, 2014
    Posts:
    4
    I reverted back to Unity 2017.1.0f3 from 2017.1.0p4 and applied the patch. Haven't had the issue since, thanks!
     
  44. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    Based upon the responses here I'm going to get this fix into 2017.1 and above. If anyone still experiences the issue after using the modified DLLs then we can address it as the reports come in.
     
  45. dCalle

    dCalle

    Joined:
    Dec 16, 2013
    Posts:
    27
    yeah me too consistently through all the .02 betas... and yeah replacing the dll and mdb made unity instantly crash^^ did you already put that in the new beta?
     
  46. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    The fix will land in both 2017.1 an 2017.2. I will update this thread once I know which releases it will land in.
     
  47. SmShadows

    SmShadows

    Joined:
    Jul 14, 2016
    Posts:
    4
    It seems to work. I haven't encountered the issue since replacing the dll yesterday.
     
  48. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,172
    FYI this bug looks to be triggering hard crashes with .NET 4.6 enabled. Guessing it's just triggering another known bug that I happened on using Rewired. .NET 4.6 seems to be particularly susceptible to dll's not being loaded or unloaded at the exact right time/place.
     
  49. wprevett

    wprevett

    Joined:
    Aug 12, 2017
    Posts:
    9
    Is this still an issue in 2017.2.0b9?
     
  50. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    The fix has not yet landed for 2017.1 and 2017.2. I will update this thread once it happens.