2024. 5. 9. 11:32
Unity/C#
원문링크 :
[Solved] How to start DragAndDrop action so that SceneView and Hierarchy accept it like with prefabs
Edit: Solution below. I'm building a level design tool which shows a list of prefabs in a custom editor window and lets users drag and drop these...
forum.unity.com
이 코드는 내가 만든게 아니고 위 링크에서 가져와 간소화 한것일뿐이다
void OnEnable()
{
SceneView.duringSceneGui += OnSceneGUI;
EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyGUI;
}
void OnDisable()
{
SceneView.duringSceneGui -= OnSceneGUI;
EditorApplication.hierarchyWindowItemOnGUI -= OnHierarchyGUI;
}
void OnSceneGUI(SceneView obj)
{
HandleDragAndDropEvents();
}
void OnHierarchyGUI(int instanceID, Rect selectionRect)
{
HandleDragAndDropEvents();
}
void HandleDragAndDropEvents()
{
if (Event.current.type == EventType.DragUpdated)
{
OnDragUpdated();
}
if (Event.current.type == EventType.DragPerform)
{
OnDragPerform();
}
}
void OnDragUpdated()
{
Debug.Log("OnDragUpdated()");
}
void OnDragPerform()
{
Debug.Log("OnDragPerform()");
}
아바타 툴 만들때 사용되었다
'Unity > C#' 카테고리의 다른 글
유니티 라이트 레졸루션 개별설정 (0) | 2024.05.12 |
---|---|
AutomaticShadowDistance (0) | 2024.04.18 |
c# Dictionary(딕셔너리) 관련 (0) | 2024.03.19 |