# Unity Freezes During Compilation

**URL:** <https://qa.fmod.com/t/unity-freezes-during-compilation/16926>\
**Category:** Unity\
**Created:** [March 23, 2021, 2:50pm UTC](https://qa.fmod.com/t/unity-freezes-during-compilation/16926 "2021-03-23T14:50:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NikMikk](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/nikmikk/32/5599_2.png) [@NikMikk](https://qa.fmod.com/u/NikMikk)\
**Post date:** [March 23, 2021, 2:50pm UTC](https://qa.fmod.com/t/unity-freezes-during-compilation/16926/1 "2021-03-23T14:50:13Z")

</div>

Hi everyone, sometimes when we do changes to our code and unity compiles it just freezes after FMOD’s `HandleBeforeAssemblyReload`

```
static EditorUtils()
{
	EditorApplication.update += Update;
	AssemblyReloadEvents.beforeAssemblyReload += HandleBeforeAssemblyReload; <----
	EditorApplication.playModeStateChanged += HandleOnPlayModeChanged;
	EditorApplication.pauseStateChanged += HandleOnPausedModeChanged;
}

```

This is the last entry in my Editor.log, is this caused by FMOD?

```
Start importing Assets/Scripts/Audio/AudioManager.cs using Guid(5eff8baf2f76c714abbeca01bc9196f0) Importer(-1,00000000000000000000000000000000)
Done importing asset: 'Assets/Scripts/Audio/AudioManager.cs' (target hash: '6bb0fef94eaf57b32c2801efaa6aeea7') in 0.101558 seconds
AssetDatabase: script compilation time: 0.043452s
- Starting script compilation
- Starting compile Library/ScriptAssemblies/Assembly-CSharp.dll
- Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll in 0,63043 seconds
- Starting compile Library/ScriptAssemblies/Assembly-CSharp-Editor.dll
- Finished compile Library/ScriptAssemblies/Assembly-CSharp-Editor.dll in 0,332747 seconds
- Finished script compilation in 0,991776 seconds
Assets\Scripts\CassettePlayerInterference.cs(9,37): warning CS0108: 'CassettePlayerInterference.particleSystem' hides inherited member 'Component.particleSystem'. Use the new keyword if hiding was intended.
Assets\Scripts\Scene Transition\SceneTransitionTrigger.cs(8,34): warning CS0108: 'SceneTransitionTrigger.collider' hides inherited member 'Component.collider'. Use the new keyword if hiding was intended.
Assets\Scripts\Unit\GhostController.cs(45,31): warning CS0108: 'GhostController.collider' hides inherited member 'Component.collider'. Use the new keyword if hiding was intended.
Assets\Scripts\Unit\PlayerInteractionEffect.cs(5,37): warning CS0108: 'PlayerInteractionEffect.renderer' hides inherited member 'Component.renderer'. Use the new keyword if hiding was intended.
Assets\Scripts\FishController.cs(9,11): warning CS0414: The field 'FishController.myTime' is assigned but its value is never used
Assets\Scripts\Managers & Controllers\Multiplatform\Platforms\Switch\SwitchStorage.cs(18,34): warning CS0414: The field 'SwitchStorage.fileHandle' is assigned but its value is never used
Assets\Scripts\Managers & Controllers\CameraController.cs(29,48): warning CS0414: The field 'CameraController.lookAtSpeed' is assigned but its value is never used
Assets\Scripts\DragRotate.cs(12,28): warning CS0414: The field 'DragRotate.accel' is assigned but its value is never used
Assets\Scripts\MotionTransform.cs(52,10): warning CS0414: The field 'MotionTransform.jumpToEnd' is assigned but its value is never used
Assets\Scripts\UI\Ui System\UiCursor.cs(23,40): warning CS0414: The field 'UiCursor.cursorScale' is assigned but its value is never used
Assets\Scripts\Managers & Controllers\Menus\FishingCanvas.cs(63,76): warning CS0414: The field 'FishingCanvas.rotateCamera' is assigned but its value is never used
Assets\Scripts\GhostCupController.cs(33,10): warning CS0414: The field 'GhostCupController.minigameActive' is assigned but its value is never used
Reloading assemblies after forced synchronous recompile.
Begin MonoManager ReloadAssembly
FMOD Studio: Destroying editor system instance
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Log (object)
FMODUnity.EditorUtils:DestroySystem () (at Assets/Plugins/FMOD/src/Editor/EditorUtils.cs:225)
FMODUnity.EditorUtils:HandleBeforeAssemblyReload () (at Assets/Plugins/FMOD/src/Editor/EditorUtils.cs:170)
UnityEditor.AssemblyReloadEvents:OnBeforeAssemblyReload ()
 
(Filename: Assets/Plugins/FMOD/src/Editor/EditorUtils.cs Line: 225)
```

---

<div class="post-metadata">

**Author:** ![NikMikk](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/nikmikk/32/5599_2.png) [@NikMikk](https://qa.fmod.com/u/NikMikk)\
**Post date:** [March 23, 2021, 2:51pm UTC](https://qa.fmod.com/t/unity-freezes-during-compilation/16926/2 "2021-03-23T14:51:56Z")

</div>

Usually only happens when Recompiling after I’ve been inside play mode. I have `Recompile After Finished Playing` checked inside unity.

---

<div class="post-metadata">

**Author:** ![NikMikk](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/nikmikk/32/5599_2.png) [@NikMikk](https://qa.fmod.com/u/NikMikk)\
**Post date:** [March 29, 2021, 3:11pm UTC](https://qa.fmod.com/t/unity-freezes-during-compilation/16926/3 "2021-03-29T15:11:56Z")

</div>

This was fixed by adding `AssemblyReloadEvents.beforeAssemblyReload += Destroy;` to `RuntimeManager.cs` as shown below. 🙂

```
FMOD.RESULT Initialize()
{
	#if UNITY_EDITOR
	AssemblyReloadEvents.beforeAssemblyReload += Destroy;
	EditorApplication.playModeStateChanged += HandlePlayModeStateChange;
	#endif // UNITY_EDITOR
	....
}
```

---

<div class="post-metadata">

**Author:** ![ben\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ben_fmod/32/1452_2.png) [@ben\_fmod](https://qa.fmod.com/u/ben_fmod)\
**Post date:** [April 7, 2021, 4:41am UTC](https://qa.fmod.com/t/unity-freezes-during-compilation/16926/4 "2021-04-07T04:41:50Z")

</div>

Thanks for letting us know about this. We have a similar fix coming out in the next release (2.01.09), which should be available soon.

---

<div class="post-metadata">

**Author:** ![ben\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ben_fmod/32/1452_2.png) [@ben\_fmod](https://qa.fmod.com/u/ben_fmod)\
**Post date:** [April 19, 2021, 6:28am UTC](https://qa.fmod.com/t/unity-freezes-during-compilation/16926/5 "2021-04-19T06:28:35Z")

</div>

Release 2.01.09 with this fix is now available from [https://fmod.com/download](https://fmod.com/download).

---

<div class="post-metadata">

**Author:** ![NikMikk](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/nikmikk/32/5599_2.png) [@NikMikk](https://qa.fmod.com/u/NikMikk)\
**Post date:** [April 19, 2021, 7:50am UTC](https://qa.fmod.com/t/unity-freezes-during-compilation/16926/6 "2021-04-19T07:50:29Z")

</div>

Thanks for the poke, we’ve upgraded now 🙂
