블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-20 00:00

Unity 2021.3.37f1

----

 

기존에 Custom Debug.cs를 만들어서 Plugins 폴더에 넣고 Debug.Log 사용 유무를 제어했었는데,

스토어 둘러보다보니 Disable Logs Easy라는게 보여서 살펴보니 좋아보인다.

게다가 Free..

기존의 Debug.cs를 제거하고 이걸로 교체 함.

 

 

[링크] https://assetstore.unity.com/packages/tools/utilities/disable-logs-easy-206473

 

Disable Logs Easy | 유틸리티 도구 | Unity Asset Store

Use the Disable Logs Easy from Dev Dunk Studio on your next project. Find this utility tool & more on the Unity Asset Store.

assetstore.unity.com

 

[참조] https://blueasa.tistory.com/1024

 

디바이스에서 Debug.Log 메시지 출력하지 않도록 하기

[추가] 2024-04-17 #define으로 Editor, Device등 원하는 곳에 띄울 수 있게 약간 변형함 #if UNITY_EDITOR #define MY_DEBUG #endif using UnityEngine; using System.Collections; using System; using UnityEngine.Internal; /// /// It overrides Uni

blueasa.tistory.com

 

반응형
Posted by blueasa
, |

Log Viewer

Unity3D/Plugins / 2014. 1. 9. 14:06

가장 좋은 점은 실시간 디버깅이겠죠 역시..


일단 로그를 많이 사용들 하실텐데요..

로그를 보려면 결국 디바이스를 PC나 맥에 물려야 한다는 단점도 있습니다. 

내부적으로 인게임에서 로그를 볼 수 있는 뷰어를 만드시는 분들도 있으시겠죠.. 저도 만들려고 보니까 어셋스토어에 이미 잘 만들어진게 올라와 있더라구요..


로그 창을 띄우는 방법은 코드를 보니 터치를 한 상태에서 원을 그리는 제스쳐를 취하면 뜨는데.. 이게 Orbit Camera 같은 것을 회전시킬 때나 스크롤을 잡고 돌리다 보면 너무 자주 떠서.. 터치를 하나를 감지 하는 것에서 2개 터치 이상으로 변경하시는게 좋습니다.

장점은 팀원이 갑자기 이거 안돼요! 라고 할 때 평소에 로그를 꼼꼼히 남기셨으면 바로 팀원의 폰에서 로그를 보고 그 자리에서 문제가 무엇인지 확인이 가능합니다.. 어떤 상황인지 보고 원인 분석 하고 로그 남기고 하는 것보단 훨씬 편하더라구요..



출처 : 게임코디 Kell님


반응형

'Unity3D > Plugins' 카테고리의 다른 글

유니티 3D상에서 WebView 띄우기  (0) 2015.01.20
Loading DDS, BMP, TGA and other textures via WWW class in Unity3d  (0) 2014.04.11
Mobile Movie Texture  (0) 2013.12.03
원격 로그 플러그인  (0) 2013.11.20
IronPython  (0) 2013.10.06
Posted by blueasa
, |

[추가] 2024-04-17

#define으로 Editor, Device등 원하는 곳에 띄울 수 있게 약간 변형함

#if UNITY_EDITOR
#define MY_DEBUG
#endif

using UnityEngine;
using System.Collections;
using System;
using UnityEngine.Internal;


/// 
/// It overrides UnityEngine.Debug to mute debug messages completely on a platform-specific basis.
/// 
/// Putting this inside of 'Plugins' foloder is ok.
/// 
/// Important:
///     Other preprocessor directives than 'UNITY_EDITOR' does not correctly work.
/// 
/// Note:
///     [Conditional] attribute indicates to compilers that a method call or attribute should be 
///     ignored unless a specified conditional compilation symbol is defined.
/// 
/// See Also: 
///     http://msdn.microsoft.com/en-us/library/system.diagnostics.conditionalattribute.aspx
/// 
/// 2012.11. @kimsama
///

/// - Unity 5.x 대응(5.x에 추가된 Debug 함수 추가)
/// - isDebugBuild("Development Build") 시 return.
/// 2016-07-25 by blueasa

public static class Debug
{
    public static bool developerConsoleVisible
    {
        get { return UnityEngine.Debug.developerConsoleVisible; }
    }

    public static bool isDebugBuild
    {
        //get { return UnityEngine.Debug.isDebugBuild; }
#if MY_DEBUG
        get { return true; }
#else
        get { return false; }
#endif
    }

    public static ILogger logger
    {
        get { return UnityEngine.Debug.unityLogger; }
    }

    public static void Assert(bool condition)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Assert(condition);
    }

    public static void Assert(bool condition, string message)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Assert(condition, message);
    }

    public static void Assert(bool condition, object message)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Assert(condition, message);
    }

    public static void Assert(bool condition, UnityEngine.Object context)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Assert(condition, context);
    }

    public static void Assert(bool condition, string message, UnityEngine.Object context)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Assert(condition, message, context);
    }

    public static void Assert(bool condition, object message, UnityEngine.Object context)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Assert(condition, message, context);
    }

    public static void AssertFormat(bool condition, string format, params object[] args)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.AssertFormat(condition, format, args);
    }

    public static void AssertFormat(bool condition, UnityEngine.Object context, string format, params object[] args)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.AssertFormat(condition, context, format, args);
    }

    public static void Break()
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Break();
    }

    public static void ClearDeveloperConsole()
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.ClearDeveloperConsole();
    }

    public static void DebugBreak()
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DebugBreak();
    }

    public static void DrawLine(Vector3 start, Vector3 end)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DrawLine(start, end);
    }

    public static void DrawLine(Vector3 start, Vector3 end, Color color)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DrawLine(start, end, color);
    }

    public static void DrawLine(Vector3 start, Vector3 end, Color color, float duration)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DrawLine(start, end, color, duration);
    }

    public static void DrawLine(Vector3 start, Vector3 end, [DefaultValue("Color.white")] Color color, [DefaultValue("0.0f")] float duration, [DefaultValue("true")] bool depthTest)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DrawLine(start, end, color, duration, depthTest);
    }

    public static void DrawRay(Vector3 start, Vector3 dir)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DrawRay(start, dir);
    }

    public static void DrawRay(Vector3 start, Vector3 dir, Color color)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DrawRay(start, dir, color);
    }

    public static void DrawRay(Vector3 start, Vector3 dir, Color color, float duration)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DrawRay(start, dir, color, duration);
    }

    public static void DrawRay(Vector3 start, Vector3 dir, [DefaultValue("Color.white")] Color color, [DefaultValue("0.0f")] float duration, [DefaultValue("true")] bool depthTest)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.DrawRay(start, dir, color, duration, depthTest);
    }

    public static void Log(object message)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Log(message);
    }

    public static void Log(object message, UnityEngine.Object context)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.Log(message, context);
    }

    public static void LogAssertion(object message)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogAssertion(message);
    }

    public static void LogAssertion(object message, UnityEngine.Object context)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogAssertion(message, context);
    }

    public static void LogAssertionFormat(string format, params object[] args)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogAssertionFormat(format, args);
    }

    public static void LogAssertionFormat(UnityEngine.Object context, string format, params object[] args)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogAssertionFormat(context, format, args);
    }

    public static void LogError(object message)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogError(message);
    }

    public static void LogError(object message, UnityEngine.Object context)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogError(message, context);
    }

    public static void LogErrorFormat(string format, params object[] args)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogErrorFormat(format, args);
    }

    public static void LogErrorFormat(UnityEngine.Object context, string format, params object[] args)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogErrorFormat(context, format, args);
    }

    public static void LogException(Exception exception)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogException(exception);
    }

    public static void LogException(string exception)
    {
        Exception ex = new Exception(exception);
        UnityEngine.Debug.LogException(ex);
    }

    public static void LogException(Exception exception, UnityEngine.Object context)
    {
        //if (false == isDebugBuild)
        //    return;

        UnityEngine.Debug.LogException(exception, context);
    }

    public static void LogFormat(string format, params object[] args)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.LogFormat(format, args);
    }

    public static void LogFormat(UnityEngine.Object context, string format, params object[] args)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.LogFormat(context, format, args);
    }

    public static void LogWarning(object message)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.LogWarning(message);
    }

    public static void LogWarning(object message, UnityEngine.Object context)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.LogWarning(message, context);
    }

    public static void LogWarningFormat(string format, params object[] args)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.LogWarningFormat(format, args);
    }

    public static void LogWarningFormat(UnityEngine.Object context, string format, params object[] args)
    {
        if (false == isDebugBuild)
            return;

        UnityEngine.Debug.LogWarningFormat(context, format, args);
    }
}

 

 

 

----

Unity에서 프로그래밍할 때 콘솔에 디버깅이나 경고 혹은 에러 문자열 출력을 위해서 Debug.Log 의 메시지 출력 메소드를 많이 사용합니다. 
 
문제는 Debug.Log 메소드의 이름과 달리 해당 콘솔 출력이 디바이스에 deploy해서 실행할 때에도 실행이 된다는 점입니다. 
 
처음부터 Debug.Log 메시지를 대체하는 별도의 wrapper 클래스나 메소드를 작성해서 사용한 경우라면 문제가 되지 않지만, 프로젝트 내에 이미 수 많은 Debug.Log 메시지들이 존재하는 경우, 변경이 번거로울 수 있습니다. 
 
이 때 사용할 수 있는 간단한 방법이 .NET의 System.Diagnostics.Conditional 속성을 사용하는 것입니다.
 
public static class Debug
{ 
[System.Diagnostics.Conditional("UNITY_EDITOR")]
public static void Log (object message)
{
UnityEngine.Debug.Log (message);
}
}
 
전체 코드는 아래 링크의 gist에서 확인할 수 있습니다.
 
 
Debug 클래스에는 Debug.Log 뿐만 아니라 UnityEngine.Debug 클래스의 DrawLine, DrawRay 등을 포함한 모든 메소드들에 대한 대체 메소드들을 포함하고 있습니다.
 
사용 방법은 링크의 전체 코드를 Assets 폴더 내의 Editor 폴더에 저장하면 됩니다.
사용 방법은 링크의 전체 코드를 Assets 폴더 내의 Plugins 폴더에 저장하면 됩니다.

 

 

[출처] http://www.unitystudy.net/bbs/board.php?bo_table=writings&wr_id=60&page=0&sca=&sfl=&stx=&spt=0&page=0&cwin=#c_322

 

 

 

[추가][Unity 5.3 이상]

It works.
And, Unity 5.3 provides an easier solution: Debug.logger.logEnabled=false to disable it.



[출처] https://gist.github.com/kimsama/4123043

 

반응형
Posted by blueasa
, |