====== 090 Debug.Logの制御 ====== ===== 概要 ===== UnityデフォルトのDebugクラスを上書きして、実機確認時にはログを出さない様にします。 ==== ソースコード ==== #if !UNITY_EDITOR #define DEBUG_LOG_OVERWRAP #endif using UnityEngine; #if DEBUG_LOG_OVERWRAP public static class Debug { static public void Break() { if(IsEnable()) { UnityEngine.Debug.Break(); } } static public void Log( object message ) { if( IsEnable() ) { UnityEngine.Debug.Log( message ); } } static public void Log( object message, Object context ) { if( IsEnable() ) { UnityEngine.Debug.Log( message, context ); } } static public void LogWarning( object message) { if( IsEnable() ) { UnityEngine.Debug.LogWarning( message ); } } static public void LogWarning(object message, Object context) { if (IsEnable()) { UnityEngine.Debug.LogWarning(message, context); } } static public void LogError( object message) { if( IsEnable() ) { UnityEngine.Debug.LogError( message ); } } static public void LogError( object message, Object context ) { if( IsEnable() ) { UnityEngine.Debug.LogError( message, context ); } } static bool IsEnable() { return UnityEngine.Debug.isDebugBuild; } } #endif // #if DEBUG_LOG_OVERWRAP