Skip to content

Instantly share code, notes, and snippets.

@TsubameUnity
Created December 18, 2018 01:34
Show Gist options
  • Save TsubameUnity/8abd3fc13ddda0caa444724816fb4c80 to your computer and use it in GitHub Desktop.
Save TsubameUnity/8abd3fc13ddda0caa444724816fb4c80 to your computer and use it in GitHub Desktop.
ゲーム実行中にスクリプト変更した場合、ゲーム実行を停止させるエディタ拡張
using UnityEngine;
using UnityEditor;
public class StopExcuteIfHotReloading {
[RuntimeInitializeOnLoadMethod]
static void StartUp() {
EditorApplication.update += EditorUpdate;
}
static void EditorUpdate() {
if (EditorApplication.isPlaying && EditorApplication.isCompiling) {
EditorApplication.isPlaying = false;
}
if (!EditorApplication.isPlaying) {
EditorApplication.update -= EditorUpdate;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment