using UnityEngine;
using UnityEditor;

public class MyEditor : EditorWindow
{
    private static EditorWindow window;
    private static float width = 600;
    private static float height = 600;

    [MenuItem("CustomWindow/MyEditor")] //상단 메뉴에 추가됩니다.
    public static void Open ()
    {
        window = GetWindow<MyEditor>();

        Rect main = EditorGUIUtility.GetMainWindowPosition(); //전체 화면 크기를 갖고 옵니다.

        window.minSize = window.maxSize = new Vector2(width, height); //시작 사이즈를 width, height로 만들어 주고

        window.minSize = new Vector2(200, 200);
        window.maxSize = new Vector2(main.width, main.height); //제한을 풀어줍니다.

        //window.position에 x, y 좌표와 width, height가 들어있습니다.
        window.position = new Rect((main.width - width) * 0.5f, (main.height - height) * 0.5f, width, height);
    }

    private void OnGUI()
    {
        GUILayout.Label("Hello!");
    }
}

 

[MenuItem("CustomWindow/MyEditor")] 를 통해 메뉴가 상단에 추가 된 모습

 

윈도우 창이 실행 된 모습. 가운데에 위치하게 됩니다. (전체화면으로 한 경우만!)

유니티 에디터에 대해 독학 중인데 엄청난 뻘짓들을 하고 있습니다..

가끔씩 이상한데 꽂혀서 시간을 많이 쓰네요.. ㅠ_ㅠ

 

찾아보면 기능들이 다양하고 많네요 ' - '@

시간이 되면 만져 본 것들을 하나씩 정리해보기!

+ Recent posts