unity - 시각적 디버깅Visual Debugging

시각적으로 디버깅함으로 직관적으로 디버깅 할수 있다.

기즈모를 키면 인게임에서도 확인할 수 있다.



결과화면


코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class VisualDebugging : MonoBehaviour {
    
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.blue;
        // 드로우 레이
        Gizmos.DrawRay(transform.position, transform.forward.normalized * 4.0f);
 
        Gizmos.color = Color.red;
        // 원을 그림
        Gizmos.DrawWireSphere(transform.position, 3.0f);
 
        // 기즈모 색상을 원 상태로.
        Gizmos.color = Color.white;
    }
}
 
cs
참고 서적 : 유니티 C# 스크립팅 마스터하기

댓글