mirror of
https://github.com/Siccity/xNode.git
synced 2026-02-06 15:24:55 +08:00
Added Drop event to Node Graph (#157)
Override NodeGraphEditor.OnDropObjects to deal with items dropped into the graph through DragAndDrop
This commit is contained in:
parent
8d64843d42
commit
9b239c3564
@ -52,6 +52,14 @@ namespace XNodeEditor {
|
||||
wantsMouseMove = true;
|
||||
Event e = Event.current;
|
||||
switch (e.type) {
|
||||
case EventType.DragUpdated:
|
||||
case EventType.DragPerform:
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
||||
if (e.type == EventType.DragPerform) {
|
||||
DragAndDrop.AcceptDrag();
|
||||
graphEditor.OnDropObjects(DragAndDrop.objectReferences);
|
||||
}
|
||||
break;
|
||||
case EventType.MouseMove:
|
||||
//Keyboard commands will not get correct mouse position from Event
|
||||
lastMousePosition = e.mousePosition;
|
||||
|
||||
@ -70,6 +70,11 @@ namespace XNodeEditor {
|
||||
return NodeEditorPreferences.GetTypeColor(type);
|
||||
}
|
||||
|
||||
/// <summary> Deal with objects dropped into the graph through DragAndDrop </summary>
|
||||
public virtual void OnDropObjects(UnityEngine.Object[] objects) {
|
||||
Debug.Log("No OnDropItems override defined for " + GetType());
|
||||
}
|
||||
|
||||
/// <summary> Create a node and save it in the graph asset </summary>
|
||||
public virtual void CreateNode(Type type, Vector2 position) {
|
||||
XNode.Node node = target.AddNode(type);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user