mirror of
https://github.com/Xevion/Boids.git
synced 2025-12-06 03:14:25 -06:00
Add Hot-reload/recompiling play mode lock
This commit is contained in:
37
Boids/Assets/DisableScriptReload.cs
Normal file
37
Boids/Assets/DisableScriptReload.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Prevents script compilation and reload while in play mode.
|
||||
/// The editor will show a the spinning reload icon if there are unapplied changes but will not actually
|
||||
/// apply them until playmode is exited.
|
||||
/// Note: Script compile errors will not be shown while in play mode.
|
||||
/// Derived from the instructions here:
|
||||
/// https://support.unity3d.com/hc/en-us/articles/210452343-How-to-stop-automatic-assembly-compilation-from-script
|
||||
/// </summary>
|
||||
[InitializeOnLoad]
|
||||
public class DisableScriptReload
|
||||
{
|
||||
static DisableScriptReload()
|
||||
{
|
||||
EditorApplication.playModeStateChanged
|
||||
+= OnPlayModeStateChanged;
|
||||
}
|
||||
|
||||
static void OnPlayModeStateChanged(PlayModeStateChange stateChange)
|
||||
{
|
||||
switch (stateChange) {
|
||||
case (PlayModeStateChange.EnteredPlayMode): {
|
||||
EditorApplication.LockReloadAssemblies();
|
||||
Debug.Log ("Assembly Reload locked as entering play mode");
|
||||
break;
|
||||
}
|
||||
case (PlayModeStateChange.ExitingPlayMode): {
|
||||
Debug.Log ("Assembly Reload unlocked as exiting play mode");
|
||||
EditorApplication.UnlockReloadAssemblies();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
3
Boids/Assets/DisableScriptReload.cs.meta
Normal file
3
Boids/Assets/DisableScriptReload.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a46ee76c3b4473f9aff1b62cf8674dc
|
||||
timeCreated: 1589846269
|
||||
Reference in New Issue
Block a user