Get it on Google Play Get it on Google Play Get it on Google Play


Wm뮤 :: 유니티 프리팹 드래그 드랍

블로그 이미지
가끔 그림그리거나 3D모델링하거나
취미로 로봇만드는
전자과 게임프로그래머 (퇴사함)
2022.3.22f1 주로 사용
모카쨩
@Ahzkwid

Recent Comment

Archive


2024. 5. 9. 11:32 Unity/C#

 

 

 

 

원문링크 : 

https://forum.unity.com/threads/solved-how-to-start-draganddrop-action-so-that-sceneview-and-hierarchy-accept-it-like-with-prefabs.822531/

 

[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
posted by 모카쨩

저사양 유저용 블로그 진입