Custom Editor Window - GUI

Unity 2017. 5. 2. 21:26
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
 
public class BugReportWindow : EditorWindow {
 
    int normalTextSize;
    string windowTitle;
    Object source;
    int num = 0;
 
    [MenuItem("내가만든메뉴/내가만든윈도우")]
    static void Init()
    {
        BugReportWindow window = (BugReportWindow)EditorWindow.GetWindow(typeof(BugReportWindow));
        window.titleContent.text = "내가만든윈도우";       
        window.Show();
    }
 
    private void OnGUI()
    {
        GUILayout.BeginVertical();
        GUILayout.Space(10);
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        normalTextSize = GUI.skin.label.fontSize;
        GUI.skin.label.fontSize = 25;
        GUILayout.Label("연습중");
        GUI.skin.label.fontSize = normalTextSize;
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
 
        GUILayout.Space(10);
        windowTitle = EditorGUILayout.TextField("제목을 적어주세요", windowTitle, GUILayout.Width(300));
        GUILayout.Label("씬 : " + EditorSceneManager.GetActiveScene().path);
        GUILayout.Label("시간 : " + System.DateTime.Now.ToString());
        source = EditorGUILayout.ObjectField("오브젝트", source, typeof(Object), true);
 
 
        GUILayout.BeginHorizontal();
        GUILayout.Label(num.ToString());
        if (GUILayout.Button("+"))
            num++;
 
        if (GUILayout.Button("-"))
            num--;
 
        GUILayout.EndHorizontal();
    }
}




'Unity' 카테고리의 다른 글

Custom Inspector  (0) 2017.05.03
EditorWindow 사용예  (0) 2017.05.02
Editor Scripting Tip [Built-in Attribute]  (0) 2017.05.02
unity gitignore 파일  (0) 2017.03.07
스크립트에서 게임의 실행을 일시정지  (0) 2017.03.03
Posted by 빵원군
,