エディタでアプリを実行している場合、例外が発生したらそこで実行を停止して欲しいので以下のようなスクリプトを書いた。
Autorun.cs
using UnityEngine;
using System.Collections;
/// <summary>
/// Editorでのスクリプト起動時に初期化処理を実行
/// </summary>
[UnityEditor.InitializeOnLoad]
public class Autorun : MonoBehaviour {
static Autorun() {
Debug.Log ("*** Debug.Log hooked by Autorun.LogCallbackHandler()");
Application.RegisterLogCallback(LogCallbackHandler);
}
static void LogCallbackHandler(string condition, string stackTrace, LogType type) {
if (type == LogType.Exception) {
// Unity Editor 上で実行中の場合のみ実行を一時停止する
if (UnityEditor.EditorApplication.isPlaying) {
UnityEditor.EditorApplication.isPaused = true;
}
}
}
}
参考: Uncaught exception doesn't kill the application - Unity Answers