Search Unity

Script changes don't compile

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

  1. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,615
    So as I understand @lukaszunity , the complaint is that while the loading process works as you explained, Unity first, asmdef second and then everything else.

    The problem is that the first error in any asmdef, block any other asmdef being compiled and loaded.

    So any one asmdef failure results in no asmdef's being loaded which makes it a lot harder to diagnose and resolve compile issue. And if there are multiple errors in each asmdefs, this is creating terrible reload times due to having to keep reloading fixing one issue at a time.

    Ideally, one failure shouldn't stop the compilation of all asmdefs, compilation should continue and load all Successful built components.

    So the build should:

    • Load the Unity engine / editor dlls'
    • Compile all asmdef's, regardless of failure. Load successfully built asmdef's, don't load ONLY those that fail.
    • Compile user code, regardless of previous failures. report new issues if there are dependancies.
    Aim is to avoid lengthy rebuild / reload times between fixing defects. A dev should be able to asses and fix all issues in a single build (preferably) instead of constantly having to rebuild for each fix.
     
  2. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    I think adding a option to not stop compiling on the first error in the editor would be a nice feature, so you can resolve multiple issues in one pass, as you mention.

    Changing the reload behaviour to support scenarios where there are compile errors, is a much more invasive change that has implications that could break partly break the project until the compile errors are fixed, as I mentioned earlier in this thread.
     
  3. StephenHodgson-Valorem

    StephenHodgson-Valorem

    Joined:
    Mar 8, 2017
    Posts:
    148
    @lukaszunity That's not what I was asking. Please take a moment to listen to what we're trying to propose.

    Could you break down exactly how the editor handles reloading assemblies right now (not on startup)?

    As far as I understand it (please correct me if I'm wrong):

    1. User edits a script.
    2. Editor unloads player assemblies.
    3. Editor compiles assemblies.
    4. If an error occurs then the Editor stops compiling and reloads old assemblies.
    5. if no error occurs then the Editor loads new assemblies

    Is this correct?
    Ideally we're asking to know if it's possible to have the following:

    1. User edit a script.
    2. Editor unloads player assemblies
    3. Editor compiles assemblies
    4. if an error occurs then the editor stops compiling
    5. Editor loads successfully built assemblies.

    I have a POC here for something similar to this using just the Assembly Builder that just kicks off a new build after the main editor loop is done. Thoughts?
     
  4. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    There is no distinction between player assemblies and editor assemblies in the editor. All assemblies are equal and all loaded into the same .NET Application domain.

    Reload works like this.

    1) Recompile scripts
    2) If there are 0 compile errors goto 3)
    3) Unload the .NET Application Domain and all assemblies (player and editor) in it.
    4) Create a new .NET Application Domain and load the new version of all assemblies (player and editor) into it.
     
  5. StephenHodgson-Valorem

    StephenHodgson-Valorem

    Joined:
    Mar 8, 2017
    Posts:
    148
    That makes a lot more sense now, thanks.
     
  6. StephenHodgson-Valorem

    StephenHodgson-Valorem

    Joined:
    Mar 8, 2017
    Posts:
    148
    Is there a way that we can at least create a new domain with the successfully built assemblies and leave the broken ones out?
     
  7. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    411
    That would be possible and so would trying to old the old assemblies. Both scenarios could create issues that can could then only be resolved by fixing the compile errors and reloading all assemblies. E.g. the model we have today.

    The point I'm trying to get across is that even if there are some issues with the current model of how assemblies are reloaded, the alternatives also have their own share of issues.
     
  8. StephenHodgson-Valorem

    StephenHodgson-Valorem

    Joined:
    Mar 8, 2017
    Posts:
    148
    Thanks for taking the time to break this down for us.

    I'd def open to the idea of making this optional and seeing where it goes.

    In the meantime, having something that detects if the error is from using a missing language feature and having the editor prompt you to switch and reload the editor using the 4.x instead of the 3.5 scripting runtime would pretty much make this a non issue for me.
     
  9. StephenHodgson-Valorem

    StephenHodgson-Valorem

    Joined:
    Mar 8, 2017
    Posts:
    148
    @lukaszunity does it makes since to not stop on the first compile if importing an asset package and there were previously no compile errors?

    For example:

    1. No compile errors in project.
    2. User imports an asset package
    3. Editor does not stop on first error, like when starting the editor for the first time.
     
  10. JamesNBishop

    JamesNBishop

    Joined:
    Feb 2, 2017
    Posts:
    1
    just updated to 2018.1.7f1 using win 7 64.....same issue
     
  11. Scriptox

    Scriptox

    Joined:
    Aug 4, 2018
    Posts:
    1
    Hi I had the same problem of refresh in the compilation of my scripts but I solved this problem here is the solution:

    So I use the version 2018.1.9.f1 of "UNITY ENGINE" and it is a solution to my specific problem so if for you it helped you so much better if the problem is elsewhere I think.

    I'm also on VisualStudio 2017, it's gone.

    PS: I'm French sorry for the mistakes of hortograph :)

    Then go to "Edit" then:
    Go to "Preferences" then
    Go to "General" then
    Click on "Auto resfresh" Voila

    So I solve my problem like this by hoping to have helped someone :)
     
  12. bartofzo

    bartofzo

    Joined:
    Mar 16, 2017
    Posts:
    56
    I ran into this issue with Unity 2018.2.1f1.
    All of the sudden changes I made in my scripts didn't compile in Unity.

    I haven't read the whole thread, but I did find a fix for my case.

    For me it was due to a compile error that did not get logged to the console about Unity's Networking MessageBase serialization. I was had a List<Vector3> public member in a class derived from MessageBase. After restarting Unity I noticed this message in the console (it wasn't there before the whole time). Removed that code and everything was working again. Maybe this is helpful for some of you?
     
  13. oguzhan-uglu

    oguzhan-uglu

    Joined:
    May 4, 2014
    Posts:
    11
    hi, i have had this issue too. auto refresh was disable and I reenabled it. 2018.2.2f1
     
  14. fatinrakib

    fatinrakib

    Joined:
    Dec 14, 2018
    Posts:
    1
    why i have this error whe importing leap module asset
    Copying assembly from 'Temp/Assembly-CSharp.dll' to 'Library/ScriptAssemblies/Assembly-CSharp.dll' failed
     
  15. brkic123antonio

    brkic123antonio

    Joined:
    Jan 11, 2019
    Posts:
    1
    Guys I made a little project and then I got an update notification. i updated to 2018.3.1f1 and VS kinda changed. I tried to write some code and it just won't compile.