Script compilation take so long time

Hi everyone,

Everytime after i change a script and return Unity Editor, it takes so long time to finish recompile the script. It takes about 2 minutes, this is terrible.
I dont know when i get this trouble, maybe after i update new version of Unity IAP then it alerts need update something then i click “Go Ahead”.
this Unity Editor log when i recompiling the script. It stuck at “Starting compile Library/ScriptAssemblies/Assembly-CSharp.dll” for a long time, about 2 minutes.

Refresh: detecting if any assets need to be imported or removed …

Hashing assets … 0.002 seconds file open: 0.000 seconds (2 files) file read: 0.002 seconds (0.003 MB) hash: 0.000 seconds ----- Compute hash(es) for 1 asset(s).

Refresh: elapses 0.489672 seconds Updating Assets/Scripts/GameController/DialogController/RankingDialog.cs - GUID: cbc9af290c43947ffa2233d136cbe177… done. [Time: 65.871205 ms] Refreshing native plugins compatible for Editor in 2.57 ms, found 2 plugins. Preloading 1 native plugins for Editor in 0.41 ms.

----- Total AssetImport time: 0.473855s, AssetImport time: 0.355585s, Asset hashing: 0.002086s [2.9 KB, 1.365381 mb/s]

  • Starting compile Library/ScriptAssemblies/Assembly-CSharp.dll

-----Compiler Commandline Arguments: Filename: /Applications/Unity2017/Unity.app/Contents/MonoBleedingEdge/bin/mono Arguments: ‘/Applications/Unity2017/Unity.app/Contents/MonoBleedingEdge/lib/mono/4.5/mcs.exe’ @ /UnityTempFile-fb6ecf7e66ae44152851b203d443c3ff index: 85 Responsefile: Temp/UnityTempFile-fb6ecf7e66ae44152851b203d443c3ff Contents: -debug -target:library -nowarn:0169 -langversion:4 -out:‘Temp/Assembly-CSharp.dll’ -unsafe -r:‘/Applications/Unity2017/Unity.app/Contents/Managed/UnityEditor.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/Managed/UnityEngine.dll’ -r:‘Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/TestRunner/UnityEngine.TestRunner.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/TestRunner/net35/unity-custom/nunit.framework.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/Timeline/RuntimeEditor/UnityEngine.Timeline.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/UnityAnalytics/UnityEngine.Analytics.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll’ -r:‘/Applications/Unity2017/Unity.app/Contents/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll’ -r:‘Assets/FacebookSDK/Plugins/Facebook.Unity.dll’ -r:‘Assets/FacebookSDK/Plugins/Settings/Facebook.Unity.Settings.dll’ -r:‘Assets/Plugins/Photon3Unity3D.dll’ -r:‘Assets/Plugins/UnityChannel/ChannelPurchase.dll’ -r:‘Assets/Plugins/UnityChannel/UnityStore.dll’ -r:‘Assets/Plugins/UnityPurchasing/Bin/Editor.dll’ -r:‘Assets/Plugins/UnityPurchasing/Bin/Purchasing.Common.dll’ -r:‘Assets/Plugins/UnityPurchasing/Bin/Stores.dll’ -r:‘Assets/Plugins/UnityPurchasing/Bin/Apple/Apple.dll’ -r:‘Assets/Plugins/UnityPurchasing/Bin/Facebook/FacebookStore.dll’ -r:‘Assets/Plugins/UnityPurchasing/Bin/Security/live/Security.dll’ -r:‘Assets/Plugins/UnityPurchasing/Bin/Tizen/Tizen.dll’ -r:‘Assets/Plugins/UnityPurchasing/winrt/winrt.dll’ -r:‘Assets/Plugins/WebSocket/websocket-sharp.dll’ -r:‘Assets/UnityAssets/AmplifyColor/Plugins/AmplifyColor.dll’ -r:‘Assets/UnityAssets/AstarPathfindingProject/Plugins/Clipper/Pathfinding.ClipperLib.dll’ -r:‘Assets/UnityAssets/AstarPathfindingProject/Plugins/DotNetZip/Pathfinding.Ionic.Zip.Reduced.dll’ -r:‘Assets/UnityAssets/AstarPathfindingProject/Plugins/Poly2Tri/Pathfinding.Poly2Tri.dll’ -r:‘Assets/UnityAssets/JsonDotNet/Assemblies/Standalone/Newtonsoft.Json.dll’ -r:‘/Applications/Unity2017/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll’ -r:‘/Applications/Unity2017/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Common.dll’ -define:UNITY_5_3_OR_NEWER -define:UNITY_5_4_OR_NEWER -define:UNITY_5_5_OR_NEWER -define:UNITY_5_6_OR_NEWER -define:UNITY_2017_1_OR_NEWER -define:UNITY_2017_1_1 -define:UNITY_2017_1 -define:UNITY_2017 -define:UNITY_PURCHASING -define:UNITY_ANALYTICS -define:UNITY_ADS -define:ENABLE_AUDIO -define:ENABLE_CACHING -define:ENABLE_CLOTH -define:ENABLE_GENERICS -define:ENABLE_PVR_GI -define:ENABLE_MICROPHONE -define:ENABLE_MULTIPLE_DISPLAYS -define:ENABLE_PHYSICS -define:ENABLE_RUNTIME_NAVMESH_BUILDING …

Please help me, i can working with this trouble :frowning:

I can think of two things that affect compile time.

  • The project contains many source files.
  • The project contains some code that executes after an assembly reload.

If you use a rather new Unity version, you might want to look into Assembly Definition Files. This is Unity’s answer to long compile times. Rather than compiling everything always, you can use asm definition files to split code to multiple assemblies and Unity needs to compile only those that actually do change.

Point 2 would be code that runs in DidReloadScript for example. Perhaps InitializeOnLoad too, but this would affect the time the game needs to enter playmode too.

1 Like

Hi, thanks for your suggestions!
I’m consider about the option 2 (The project contains some code that executes after an assembly reload.)
Because before I use API Updater, it compile normally, this trouble happen only when i update API.
maybe it updated some scripts files.
But could you please tell me more detail about this?
Some kind of code that executes after an assembly reload.
I’m very appreciate if you help me. I cant work anymore with this trouble :frowning: