1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00
Renamed DropItem to OnDropObjects - Object is more consistent with what's being supplied as parameter
Removed OnDrop - Runtime classes should not have any concept of DragAndDrop as it's an editor only feature
Send entire Object array instead of one object at a time - The user might be interested in whether the objects are part of the same operation
This commit is contained in:
Thor Brigsted 2019-06-29 00:01:28 +02:00
parent 882c5e2a1d
commit b0adb856ee
3 changed files with 5 additions and 18 deletions

View File

@ -49,21 +49,14 @@ namespace XNodeEditor {
wantsMouseMove = true;
Event e = Event.current;
switch (e.type) {
case EventType.DragUpdated:
case EventType.DragPerform:
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
if (e.type == EventType.DragPerform) {
DragAndDrop.AcceptDrag();
foreach (object droppedItem in DragAndDrop.objectReferences) {
graphEditor.DropItem(droppedItem);
}
graphEditor.OnDropObjects(DragAndDrop.objectReferences);
}
break;
case EventType.MouseMove:
break;
case EventType.ScrollWheel:

View File

@ -68,8 +68,9 @@ namespace XNodeEditor {
return NodeEditorPreferences.GetTypeColor(type);
}
public virtual void DropItem(object droppedItem) {
target.OnDrop(droppedItem, NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition));
/// <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>

View File

@ -81,12 +81,5 @@ namespace XNode {
// Remove all nodes prior to graph destruction
Clear();
}
/// <summary> Is called when something is dragged in the editor </summary>
/// <param name="droppedObject">The dropped object</param>
public virtual void OnDrop(object droppedObject, Vector2 dropPosition) {
Debug.LogWarning("No OnDrop(NodePort port) override defined for " + GetType());
}
}
}