EditorWindow
2023. 9. 12. 15:42ㆍ개인적인 공부/Unity
Unity 안에서 새 창을 만들때 쓴다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class RoomNodeGraphEditor : EditorWindow
{
private GUIStyle roomNodeStyle;
// Node layout values
private const float nodeWidth = 160f;
private const float nodeHeight = 75f;
private const int nodePadding = 25;
private const int nodeBorder = 12;
[MenuItem ("Room Node Graph Editor", menuItem = "Window/Dungeon Editor/Room Graph Editor")]
private static void OpenWindow()
{
GetWindow<RoomNodeGraphEditor>("Room Node Graph Editor");
}
private void OnEnable()
{
// Define node layout style
roomNodeStyle = new GUIStyle();
roomNodeStyle.normal.background = EditorGUIUtility.Load("node1") as Texture2D;
roomNodeStyle.normal.textColor = Color.white;
roomNodeStyle.padding = new RectOffset(nodePadding, nodePadding, nodePadding, nodePadding);
roomNodeStyle.border = new RectOffset(nodeBorder, nodeBorder, nodeBorder, nodeBorder);
}
/// <summary>
/// Draw Editor Gui
/// </summary>
private void OnGUI()
{
GUILayout.BeginArea(new Rect(new Vector2(100f, 100f), new Vector2(nodeWidth, nodeHeight)), roomNodeStyle);
EditorGUILayout.LabelField("Node 1");
GUILayout.EndArea();
GUILayout.BeginArea(new Rect(new Vector2(100f, 300f), new Vector2(nodeWidth, nodeHeight)), roomNodeStyle);
EditorGUILayout.LabelField("Node 2");
GUILayout.EndArea();
}
}
새로운 창이 생성된다.
'개인적인 공부 > Unity' 카테고리의 다른 글
Blend Tree 를 이용한 Input System (0) | 2024.01.29 |
---|---|
Health Slider issue (0) | 2023.09.06 |
Remote Play 확인 (0) | 2023.08.22 |
GamePad Attack (0) | 2023.08.16 |
Gamepad movement (0) | 2023.08.15 |