Get it on Google Play


Wm뮤 :: 디버그방법모음

블로그 이미지
가끔 그림그리거나 3D모델링하거나
취미로 로봇만드는
퇴직한 전자과 게임프로그래머
2020.3.48f1 , 2022.3.6f1 주로 사용
모카쨩
@Ahzkwid

Recent Comment

Archive


2021. 2. 2. 11:21 Unity

 

 

 

디버그모드에서만 작동하는 코드

if (Debug.isDebugBuild)
{
//작동할 코드
}

 

V3

#if UNITY_EDITOR
        if (UnityEditor.EditorUserBuildSettings.development)
#else
        if (UnityEngine.Debug.isDebugBuild)
#endif
{
//작동할 코드
}

 

FPS체크

(디버그모드에서만 동작하게 해놨다)

using UnityEngine;

public class FpsViewer : MonoBehaviour
{
    float fps = 60;
    private void OnGUI()
    {
#if UNITY_EDITOR
        if (UnityEditor.EditorUserBuildSettings.development)
#else
        if (UnityEngine.Debug.isDebugBuild)
#endif
        {
            fps = Mathf.Lerp(fps, (1 / Time.deltaTime), 0.05f);
            GUI.Box(new Rect(100, 0, 200, 24), "FPS: " + (int)fps);
        }
    }
}

 

 

Debug함수들

Debug.LogError("에러문구");
Debug.LogWarning("주의문구");

//일시중지버튼. 반드시 꼭 짚고 넘어가야 하는 에러일때 사용(Editor에서만 작동)
Debug.Break();

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

중단점 사용법

 

 

 

값볼수있다

 

 

어떤 함수가 실행됐는지 확인

var methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
Debug.Log("{methodName}실행됨");

 

 

 

 

 

 

'Unity' 카테고리의 다른 글

안드로이드 빌드관련  (0) 2021.02.03
유니티 UI  (0) 2021.01.30
유니티 카메라  (0) 2021.01.27
posted by 모카쨩

  • total
  • today
  • yesterday

Recent Post

저사양 유저용 블로그 진입