Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

게임 프로그래밍

[Unity] DrawGizmos 본문

프로그래밍/유니티

[Unity] DrawGizmos

Junwe 2020. 3. 13. 02:38

유니티에서는 OnDrawGizmo와 OnDrawGizmosSelected를 이용해서 Gizemo를 그려 씬에서의 편집을 쉽게 만들 수 있습니다. 간단하게 사용 방법에 대해서 알아 보겠습니다.

 

1
2
3
4
5
6
7
8
9
using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void OnDrawGizmos() {
        Gizmos.color = Color.yellow;
        Gizmos.DrawSphere(transform.position, 1);
    }
}
cs

이렇게 OnDrawGizmos를 통해 이 함수안에 Gizmos 클래스안에 있는 것들을 사용하면 됩니다.

그 외에도 이것과 비슷한 OnDrawGizmosSelected 라는 함수도 있습니다. 차이점은 이 함수는 오브젝트가 선택될때만 Gizmos를 그린다는 점 입니다.

 

Gizmos 클래스에 대해서는 아래의 링크를 참고하시면 좋을것 같습니다.

.https://docs.unity3d.com/kr/530/ScriptReference/Gizmos.html

 

Comments