Search Unity

Script changes don't compile

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

  1. Vixxd

    Vixxd

    Joined:
    Jul 25, 2016
    Posts:
    11
    Hi there, I am using 2017.2.0f3 and Visual Studio Community for Mac 7.2 (Build 636). I am finding that if I make changes in a script (debug statements, new variables, anything) and save, it is not reflected or updated in Unity. I have to manually rebuild the solution to see my changes. Cleaning the solution also does not work.

    It used to happen infrequently and now I have to rebuild for every change.

    Just letting you know this is still persisting on my Mac (Sierra 10.12.6 (16G29))
     
  2. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    Could you report a bug on this?
     
  3. aorata

    aorata

    Joined:
    Feb 10, 2012
    Posts:
    28
    I am glad I found this, this issue made me think I was losing it. I was on 2017.1.1f1 and I just read that it had the bug. I'm updating to 2017.2.0f3

    Hopefully that'll be the end of it!
     
  4. aorata

    aorata

    Joined:
    Feb 10, 2012
    Posts:
    28
    Hey Lukaszunity, so after the update, no more of that issue with the scripts compiling but not updating in the editor, I have a bigger problem now. A game that worked perfectly is now lagging beyond comprehension. What is new between those versions of Unity that could cause it?
     
  5. VirtusH

    VirtusH

    Joined:
    Aug 18, 2015
    Posts:
    95
    Having the same issue on 2017.2.0f3.. :(

    Having a message saying "Script Compilation Successful" would save my sanity at least until you guys can get it completely fixed.
     
  6. MMOInteractiveRep

    MMOInteractiveRep

    Joined:
    Apr 7, 2015
    Posts:
    88
    I am having issues with VS 2017 as well. I am using SpatialOS so I am writing Schema scripts out side of Unity and VS and then compiling those Schema Scripts into actual code. When a new Code file is created VS isn't picking it up and updating. I have some scripts where new namespaces and classes are being recognized and then some scripts where I am unable to use the new namespaces. Some Scripts aren't even able to recognize UnityEngine when I try to add the using statement and then other scripts are working just fine. It's extremely strange.
     
  7. Brike

    Brike

    Joined:
    Aug 7, 2013
    Posts:
    4
    Same issue since I intalled Visual Studio Community 2017!!!!!

    I'm currently working with four versions at a time;

    5.6.1p1
    5.6.3p3
    2017.1.0f3
    2017.2

    ...and the problem persist in all of them.

    This never happend with older versions of Visual Studio. I don't think this issue is because of Unity.

    I downloaded VSC 2015 and fixed the problem.
    https://imagine.microsoft.com/en-us/catalog/product/101

    I hope this can help you.
     
  8. Brike

    Brike

    Joined:
    Aug 7, 2013
    Posts:
    4
    I forgot to say you need to download Visual Studio 2015 Tools for Unity, otherwise, it won't work!!
    https://marketplace.visualstudio.com/items?itemName=SebastienLebreton.VisualStudio2015ToolsforUnity

    Finally, just in case, I uninstalled everything related with VS 2017. In my case, after several tests with succed, I can assure that Unity - VS2015 works 'like a charm'!! :)
     
  9. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,971
    I'm on Unity version 5.5.1f1

    Using MonoDevelop 5.9.6

    My project became crazy. It behaves as if I had errors, except they won't show on Console. Console is 100% clean, empty. But if I try to play application, it asks to fix errors. If I try to drop script on gameObject, asks me to compile them first.

    I've tried a lot of things. Creating a new project. Importing scripts one by one. Scripts that were working perfectly, now they just wont compile.

    It's weird because some of the scripts do compile perfectly. But other scripts seems to be haunted. Once I add a haunted script into the new project, it gets jinxed.

    I've deleted the script assemblies. Auto Refresh is enabled.

    It actually shows the compiling wheel on the lower left for a thirst of a second ... and stops. Debug Console absolutely empty. But still, when I try to play application, it asks me to fix errors.

    Once the project is jinxed, changing script, commenting stuff out, seems to have no effect. I get same result.

    I have to remove all the jinxed scripts, for Unity to compile normally.

    I'm going to try reinstalling Unity now...

    EDIT:
    Reinstalled Unity, latest version. And get this error now:

    error CS1704: An assembly with the same name `UnityEngine.UI' has already been imported. Consider removing one of the references or sign the assembly



    This problem apparently can be fixed by re importing all in Assets menu.

    Thankfully everything is working again now...
     
    Last edited: Nov 10, 2017
  10. SiioSA

    SiioSA

    Joined:
    Nov 10, 2017
    Posts:
    1
    Same Issue Win 10.
    Delete Cache under <Project>\Library\PlayerDataCache & unselect 'Scripts Only Build' under Build Settings ...
    then build
     
  11. NumberZero_X

    NumberZero_X

    Joined:
    Dec 11, 2016
    Posts:
    1
    The same thing is happening to me in version 2017.2.0f3, using MonoDevelop and Windows 10. Help?
     
  12. JEONSULIN

    JEONSULIN

    Joined:
    Dec 29, 2016
    Posts:
    4
    Hey lukaszunity, I'am currently using Unity 2017.1.0f3 version and VS2017 community version on Win10. I had the same issue and I patched your UnityEditorDLL-2017.1.03f-ScriptComplieChange2 and it seems like the bug is gone now but Now I get IOException error that says ERROR_ALREADY_EXISTS. Path like this.
    upload_2017-12-4_19-28-0.png

    I thought maybe your 3rd patch would fix this problem but the link is not valid. Looking forward for your answer.

    Regards.
     
  13. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    This link works for me:
    https://files.unity3d.com/lukasz/share/UnityEditorDLL-2017.1.0f3-ScriptCompileChange3.zip

    I would also recommend trying the latest 2017.1.x release which should have the changes included.
     
  14. JEONSULIN

    JEONSULIN

    Joined:
    Dec 29, 2016
    Posts:
    4
  15. Ox1mason

    Ox1mason

    Joined:
    Jan 13, 2018
    Posts:
    1
    FWIW, I have 2017.3.0f3 and am experiencing this issue.
     
    jethrogillgren likes this.
  16. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    Hello, I had this issue previously with Unity 2017, the solution was to stop using hardlinks.

    I had a hardlink on the Library folder that I've located on another drive - an SSD for faster cache. This was working fine with Unity 5.6, but starting with Unity 2017.1 I had this "scripts not updating" issue.

    @lukaszunity Any chance for bringing back hardlinks support?
     
    TofaPT likes this.
  17. DarkVerse

    DarkVerse

    Joined:
    Jan 9, 2017
    Posts:
    57
    I have this problem too. It started a few versions of Unity back (2017.1 I think) and is the same whether I use VS 2017, 2015 or Mono. I am currently on Unity 2017.3.0f3. This is killing productivity. Every script change I have to close Unity, delete ScriptAssemblies and reopen Unity.

    What is odd is that I will sometimes (and it is rare) get two or three correct auto re-compiles before having to do this (I can tell by when I give focus back to Unity whether it has recompiled or whether I have to delete ScriptAssemblies). Almost always I have to close and delete.

    Is a fix to this any closer. It is a massive problem. I don't really want to use notepad as a script editor but it looks like that may be the go.

    Is this related to changes under the hood to split the assemblies? If we setup multiple assemblies is there a chance it may work?
     
  18. ChiaraCap

    ChiaraCap

    Joined:
    Aug 20, 2017
    Posts:
    3
    Hi,
    I have made some test and found a workaround for this problem that, for me, is working well.
    I am using Unity 2017. 3.0f3 64 bit windows 10 version and the "no change compilation" happens when I try to modify the value of a declared variable ( a=3 changed in a=5 but compiled as a=3).
    if I change the name of the variable ( from a to ab for example) and then save, the changes are applied by the compiler. Then I change again the name of the variable (from ab to a again) and the change is applied by the compiler.
    So I think that could be something in the process that recognize if a file is changed or not changed.
    I know that this workaround is not the solution at all, but in this way I can procede with my work.
    Hope this wil help some other people here
     
  19. bkimball85

    bkimball85

    Joined:
    Jan 18, 2018
    Posts:
    1
    Windows 7 x64
    VS Community 2017

    Issue exists with both Unity 2017.1.3f1 and the latest 2017.3.*
     
  20. MatthiasStuetzer

    MatthiasStuetzer

    Joined:
    Oct 5, 2016
    Posts:
    17
    Having the same issue. Introducing/removing mock variables seems a somewhat reliable workaround. But man this is costing me productivity...
     
  21. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    Which script assembly file should I delete before reopening?
     
  22. ChiaraCap

    ChiaraCap

    Joined:
    Aug 20, 2017
    Posts:
    3
    I cant believe that Unity team is not working "night and day" to solve this issue! Is this game engine reached a point of non return? Do youk now that there is people that use it for working? Please give me an answer...
     
  23. Samboi

    Samboi

    Joined:
    Jan 31, 2018
    Posts:
    1
    Scripts in Inspector not updating or refreshing. Unity 2017.3.0f.3 and Visual Studio 2017 Community
     
  24. DarkVerse

    DarkVerse

    Joined:
    Jan 9, 2017
    Posts:
    57
    Is anyone from Unity working on a solution to this?
     
  25. jethrogillgren

    jethrogillgren

    Joined:
    Jan 11, 2017
    Posts:
    28
    This bug is also on 2017.3.1f1 VS 2017.
    Windows 10 x64

    @lukaszunity Did the bugfix regress out of the builds for 2017.3? Should I submit a bug report? Or is there an existing one to reopen? Patch logs just show
    • (none) - Scripting: Fixed an issue with Unity not using the latest changes made to scripts after recompile in Unity on Windows.

    Everything was working fine for some time, and then the problem started seemingly randomly.
    Deleting Library/ScriptAssemblies is still a valid workaround.
     
    Last edited: Feb 9, 2018
  26. ChiaraCap

    ChiaraCap

    Joined:
    Aug 20, 2017
    Posts:
    3
    The silence of Unity Tech people is something really strange... Could we have an answer please? At least something " ok, we are working at it..."
     
  27. ItsGonnaBeOk

    ItsGonnaBeOk

    Joined:
    Jul 14, 2016
    Posts:
    21
    Wierd stuff going on with my unity, if I add a script and then double click it, it opens as "other file", therefore not connected to my project. It doesnt occur however, if I just unfold VS after creating a script (without double-clicking it). It asks permission to reload the project and after doing that everything works just fine.

    Unity 2017.3.0f3
     
  28. IgorTecnalia

    IgorTecnalia

    Joined:
    Dec 22, 2017
    Posts:
    1
    I´m using Unity 2017.3.1f1 and VS 2017 Professional and I am facing the same problem.
    In my case, the workaround was to delete "..\Library\ScriptAssemblies" contents. For that reason, I made this script for Unity to delete the files. Feel free to use it:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5. using System.IO;
    6.  
    7. public class Recompile : MonoBehaviour {
    8.    
    9.     [MenuItem("CustomTools/Compile &c")]
    10.     static void Compile () {
    11.  
    12.         string path = Directory.GetCurrentDirectory() + "/Library/ScriptAssemblies";
    13.         DirectoryInfo dir = new DirectoryInfo(path);
    14.         FileInfo[] info = dir.GetFiles("*.*");
    15.         foreach (FileInfo f in info)
    16.         {
    17.             Debug.Log(f + " deleted");
    18.             f.Delete();
    19.         }
    20.     }
    21. }
     
    toomasio likes this.
  29. brubcruz

    brubcruz

    Joined:
    Feb 13, 2018
    Posts:
    3
    Same problem using Unity 2017.3.1f1 and VS 2017 comunity.
    As a workaround im forcing a compile error (sometimes had to do it twice...), hit play, remove compile error and hit play again.

    Edit: Back to normal... My problem was reading access in the Project/Temp folder created by Unity when the editor is opened.
     
    Last edited: Mar 5, 2018
  30. ReadySetAdmin

    ReadySetAdmin

    Joined:
    Apr 2, 2013
    Posts:
    2
    We ran into the same issue. Turns out auto refresh got turned off some how. Maybe some sort of hidden shortcut or was checked by default on the newest version of Unity. Either way Edit->Preferences->General->Auto refresh make sure that is checked and hopefully it will fix it for you too.
     
  31. olssondtobias

    olssondtobias

    Joined:
    Feb 15, 2018
    Posts:
    1
    Any update on this issue?
    I'm having the same problem with Unity constantly stops auto compiling when making changes in scripts. I've tried other editors than VS with the same behavior, so Unity should be the problem.
    Running Unity 2017.3.1f1.
    None of the suggested fixes/workarounds work for me. I can restart Unity and delete ScriptAssemblies to force compile, but it doesn't solve the issue so I have to do this every time I change a single line of code... It's ridiculous really.

    I've noticed that if I intentionally add an error in any of my scripts, Unity will complain and not run if I hit play (note that Unity still doesn't notice other changes that won't cause a compile error at this stage). But if I fix the error it will continue complaining about compile error until I restart the program. Thought this information might be helpful or interesting.
     
    rumit48 likes this.
  32. MarvelWild

    MarvelWild

    Joined:
    Dec 27, 2017
    Posts:
    2
    Year 2018, still doing this. One small bug can ruin all the experience
     
    rumit48 likes this.
  33. FastKillteam1

    FastKillteam1

    Joined:
    Sep 20, 2017
    Posts:
    50
    I’m running the latest version of unity as I always do. I’ve had this issue for the last few months on every version I have used. Absolute pain!!!! I’ve rebuilt scenes countless times in order to “sometimes” remedy the issue. Ui buttons not working is one, scripts not updating is the other. Everything works fine in editor then build has issues. When will there be a fix ?!!!
     
  34. Pierre-skinnerup

    Pierre-skinnerup

    Joined:
    Aug 20, 2012
    Posts:
    8
    I have been plagued by this "bug" for several month now.. can we at least get some response from Unity that its being worked on, i have tried everything from this thread and nothing works.

    i'm running Unity 2017.2.0f3 with VS code version 1.21.1..

    EDIT: I have switch from .NET 2.0 Subset to .NET 2.0 under Player and after that the "Bug" have disappeared, hope that can be of some help :)
     
    Last edited: Apr 12, 2018
    rumit48 likes this.
  35. psyop_volpe

    psyop_volpe

    Joined:
    Apr 11, 2017
    Posts:
    7
    I am seeing this happen for me in 5.6.5f1. However, I am adding code in via a C# DLL. I needed to reference the Assembly-CSharp.dll so that I could use Third-Party code that I got from the Asset Store. Ever since I added it to the CSharp Project, the only way I can get my CSharp DLL code to update is to Reimport All the assets.

    Is there a step that I missed or a fix for this issue?
     
    rumit48 likes this.
  36. pionone

    pionone

    Joined:
    Aug 23, 2016
    Posts:
    3
    I also have this problem and the only relyable solution is to restart unity. This is a huge pain for every little code change.
    Could you at least add a button to force compiling until you definitely found the bug and fixed it?
    This bug should be a #1 priority.
     
  37. Milluz

    Milluz

    Joined:
    Oct 22, 2014
    Posts:
    9
    Thank you very much dogzerx2 for the tip, I'm fighting for 4 hours trying to make Unity compile, tried to remove Unity, remove all Unity files from ~/Library(I'm using mac), user older Unity version, use other text editors, remove the Project Library folder and build every thing again and all failed.

    But reimport the assets from the editor did the work.

    Edit: Ops forgot to put the current Unity version 2017.4.1f1
     
    Last edited: Apr 12, 2018
    rumit48 likes this.
  38. rumit48

    rumit48

    Joined:
    Apr 26, 2017
    Posts:
    4
    I have the same problem. Only reimport the assets in unity editor helps.

    Unity 2017.4.1f1

    Microsoft Visual Studio Community 2017
    Version 15.5.3
    VisualStudio.15.Release/15.5.3+27130.2020
    Microsoft .NET Framework
    Version 4.7.02558

    Windows 8.1
     
  39. Joviex

    Joviex

    Joined:
    Jan 23, 2011
    Posts:
    44
    Still the same problem. Been a problem for me through multiple versions in the 2017 line.

    Unity 2017.4.1f1

    Microsoft Visual Studio Community 2017
    Version 15.6.7
    Visual Studio Tools for Unity - 3.6.0.5
    Microsoft .NET Framework
    Version 4.7.02558
     
  40. Fochino

    Fochino

    Joined:
    May 5, 2018
    Posts:
    1
    I've just installed unity for the first time yesterday and trying to play with it, and was puzzled by this bug. So even in 2018.1.0f2 is still there.
    It seems that the problem is limited to public members, all the rest update correctly but public variables don't get updated without using the "reset" command in the coggle menu. If I add a new public member unity see it immediatly, but if I change an existing one it just ignores it.
    I tried all the suggested methods, but nothing works for me.
    I'm using Visual Studio 2017 community edition, all unity and visual studio are new installation without other things added, but I think the problem is with unity, because all other modifications in script files are detected, only the public members one are ignored.
     
  41. mjunaidch

    mjunaidch

    Joined:
    Oct 23, 2016
    Posts:
    7
    I have this problem after running this (EditorPrefs.DeleteAll()) line. I have 5.6.3, in my case Auto Refresh is enabled i disable it and reopen unity and enable Auto Refresh again so its work now normally :) And I also reinstall unity.
     
  42. MMOARgames

    MMOARgames

    Joined:
    Feb 28, 2013
    Posts:
    24
    I've noticed the same thing but mine is related to the custom assemblies. They're are not reloaded if there's a compile error, but according to the docs the successfully build assemblies should be reloaded.

    According to the docs:
    This does not seem to be the case. After doing some testing I found that the "Begin MonoManager ReloadAssembly" event does not get raised after compilation is completed with errors, contrary to what the docs say.

    To test this out I made two folders

    Folder1
    -TestScript1.cs
    -TestAssembly1.amsdef
    Folder2
    -TestScript2.cs
    -TestAssembly2.amsdef

    In the TestScript1 class I subscribed to the CompilationPipeline events to make sure we're getting those dlls generated correctly.
    Code (CSharp):
    1. using System;
    2. using UnityEditor;
    3. using UnityEditor.Compilation;
    4. using UnityEngine;
    5.  
    6. [InitializeOnLoad]
    7. public static class TestScript1
    8. {
    9.     static TestScript1()
    10.     {
    11.         CompilationPipeline.assemblyCompilationStarted += CompilationPipelineOnAssemblyCompilationStarted;
    12.         CompilationPipeline.assemblyCompilationFinished += CompilationPipelineOnAssemblyCompilationFinished;
    13.     }
    14.  
    15.     private static void CompilationPipelineOnAssemblyCompilationFinished(string arg1, CompilerMessage[] arg2)
    16.     {
    17.         Debug.LogFormat("Compilation finished: {0}", arg1);
    18.         for (int i = 0; i < arg2.Length; i++)
    19.         {
    20.             switch (arg2[i].type)
    21.             {
    22.                 case CompilerMessageType.Error:
    23.                     Debug.LogError("---> " + arg2[i].message);
    24.                     break;
    25.                 case CompilerMessageType.Warning:
    26.                     Debug.LogWarning("---> " + arg2[i].message);
    27.                     break;
    28.                 default:
    29.                     throw new ArgumentOutOfRangeException();
    30.             }
    31.         }
    32.  
    33.         AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
    34.     }
    35.  
    36.     private static void CompilationPipelineOnAssemblyCompilationStarted(string obj)
    37.     {
    38.         Debug.Log("Starting Compile: " + obj);
    39.     }
    40. }

    In TestScript2 I kept clean with no extras

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class TestScript2 : MonoBehaviour { }

    After viewing the compiled output in the console, I deliberately added a compile error in TestScript2.cs and added an extra Debug.Log to TestScript1.cs in CompileFinished Event:

    Code (CSharp):
    1.  
    2. TestScript1.cs
    3. ...
    4.     private static void CompilationPipelineOnAssemblyCompilationFinished(string arg1, CompilerMessage[] arg2)
    5.     {
    6.         Debug.LogFormat("Compilation finished: {0}", arg1);
    7.         for (int i = 0; i < arg2.Length; i++)
    8.         {
    9.             switch (arg2[i].type)
    10.             {
    11.                 case CompilerMessageType.Error:
    12.                     Debug.LogError("---> " + arg2[i].message);
    13.                     break;
    14.                 case CompilerMessageType.Warning:
    15.                     Debug.LogWarning("---> " + arg2[i].message);
    16.                     break;
    17.                 default:
    18.                     throw new ArgumentOutOfRangeException();
    19.             }
    20.         }
    21.  
    22.    
    23.         Debug.LogWarning("I'm done!");
    24.         AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
    25.     }
    26. ...
    27.  
    28. TestScript2.cs
    29. ...
    30. public class TestScript2 : MonoBehaviour {
    31.  
    32.  

    After saving and switching back to the editor to watch everything compile, I noticed that my new debug line didn't get thrown, which means the successful compiled assembly was not reloaded properly.

    upload_2018-6-21_22-30-52.png

    Odd thing is, if I were to close the editor and load it back up again, the successful compiled assembly is properly reloaded by the editor on startup.
     
  43. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    @MMOARgames

    Note that this behavior with loading .asmdefs before any other assemblies is only on startup, as described in the docs:

     
  44. MMOARgames

    MMOARgames

    Joined:
    Feb 28, 2013
    Posts:
    24
    Right, but why is it only on startup and not after any script changes?

    It didn't always do this. Seems like a bug to me.
     
  45. MMOARgames

    MMOARgames

    Joined:
    Feb 28, 2013
    Posts:
    24

    Attached Files:

  46. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    It has always been the case the editor only reloads all assemblies when there are 0 compile errors, as you would otherwise unload part of your project. Which could lead to missing MonoBehaviours, editor windows disappearing and other issues.

    This is a not a regression, it has always been this way by design. The reason we can do it on startup is because we are incrementally loading the assemblies, e.g.

    1) Load UnityEngine.dll, UnityEditor.dll and other Unity assemblies. (First reload)
    2) Load precompiled assemblies, compile .asmdefs and load the ones that successfully compiled. (Second reload)
    3) If there are 0 compile errors i .asmdefs, compile and load predefined assemblies Assembly-CSharp.dll and friends. (Third reload)

    We are not unloading any assemblies on startup, just loading more and more assemblies, so this does not break the assumption that we always reload all loaded assemblies.
     
  47. MMOARgames

    MMOARgames

    Joined:
    Feb 28, 2013
    Posts:
    24
    Okay riddle me this,

    When we hit an error, why can't we at least reload the successfully compiled assemblies?
     
  48. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    All assemblies need to be reloaded together, we can't reload a subset of them.
     
  49. StephenHodgson-Valorem

    StephenHodgson-Valorem

    Joined:
    Mar 8, 2017
    Posts:
    148
    > All assemblies need to be reloaded together, we can't reload a subset of them.

    Well, from what I understand, it wouldn't be a subset because you'd have all the successfully compiled assemblies (so far), right?
     
    Last edited: Jun 25, 2018
  50. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    I was answering the question whether we could just reload part of the assemblies and keep the rest as-is in memory. We can't

    Unity currently does not support loading old and new assemblies while there are compile errors, as we will reload the latest version of all assemblies if and only if there 0 compile errors in the project.

    It can also cause issues if you have situation where you update assets and scripts in your project and there are compile errors in the new scripts. Then if you reload the old version of the assembly, then the assembly might be incompatible with the new assets somehow and cause issues. Like the data format of the assets has changed and the old assembly can no longer load them.