上記のようなスクリプトを用意すると、 下記のような構文で例外を投げることができます
using UnityEngine; public class MyBehaviourScript : MonoBehaviour { public int Level; private void Start() { // Exception: Exception of type 'System.Exception' was thrown. DebugCommon.Assert(0 < Level); // Exception: レベルの値が不正です DebugCommon.Assert(0 < Level, "レベルの値が不正です"); // Exception: レベルの値が不正です DebugCommon.Assert(0 < Level, () => "レベルの値が不正です"); } }
DebugCommon.Assert関数は、第1引数の値がfalseの場合のみ例外を投げます
http://answers.unity3d.com/questions/19122/assert-function.html