본문 바로가기
개발/Unity

Unity) 선택된 Uniy Editor 찾기 (EditorWindowDector)

by 테샤르 2024. 9. 7.

선택된 Uniy Editor 찾기 (EditorWindowDector)

 

 

 

Unity Engin에서 선택된(Focus) Editor를 찾는 간단한 기능의 코드이다.

활성화된 Editor가 변경될때마다 Console 로그로 나타낸다.

반응형

 

 < Unity Editor Window 종류 >

< 코드 >

using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public class EditorWindowDector 
{
	private static EditorWindow lastActiveWindow;

	static EditorWindowDector()
	{
		EditorApplication.update += OnEditorUpdate;
	}

	private static void OnEditorUpdate()
	{
		EditorWindow currentActiveWindow = EditorWindow.focusedWindow;

		if (currentActiveWindow != lastActiveWindow)
		{
			lastActiveWindow = currentActiveWindow;

			if (currentActiveWindow != null)
			{
				Debug.Log($"[Select EditorWindow] : <color=red>{currentActiveWindow.titleContent.text}</color>");
				EditorGUIUtility.PingObject(currentActiveWindow);
			}
		}
	}
}

 

Unity EditorWindow.focusedWindow : [링크]

 

Unity - Scripting API: EditorWindow.focusedWindow

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

 

 

★☆☆☆☆

 

반응형

댓글