Posts 유니티 에디터 GUI - 포커스 확인, 처리
Post
Cancel

유니티 에디터 GUI - 포커스 확인, 처리

1. 컨트롤 포커스 여부 확인


1
2
3
4
5
6
7
8
9
10
11
// 다음에 나올 GUI 컨트롤에 이름 부여
GUI.SetNextControlName("Foooooooocus");

// GUI 그리기
EditorGUI.TextArea(rect, value, inputStyle);

// 포커스 여부 확인
if(GUI.GetNameOfFocusedControl() == "Foooooooocus")
{
    // Do Something..
}


2. 특정 컨트롤에 포커스


1
2
3
4
5
6
7
8
// 다음에 나올 GUI 컨트롤에 이름 부여
GUI.SetNextControlName("Foooooooocus");

// GUI 그리기
EditorGUI.TextArea(rect, value, inputStyle);

// 이름 부여된 컨트롤에 포커싱
EditorGUI.FocusTextInControl("Foooooooocus);


3. 포커스 제거


1
2
3
4
// 컨트롤이 없는 부분에 마우스 클릭할 경우
// 강제로 포커스 제거
if(Event.current.type == EventType.MouseDown)
    EditorGUI.FocusTextInControl("");
This post is licensed under CC BY 4.0 by the author.