mirror of
https://github.com/Siccity/xNode.git
synced 2026-03-26 22:49:02 +08:00
Review
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:
parent
882c5e2a1d
commit
b0adb856ee
@ -49,21 +49,14 @@ namespace XNodeEditor {
|
|||||||
wantsMouseMove = true;
|
wantsMouseMove = true;
|
||||||
Event e = Event.current;
|
Event e = Event.current;
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
|
|
||||||
case EventType.DragUpdated:
|
case EventType.DragUpdated:
|
||||||
case EventType.DragPerform:
|
case EventType.DragPerform:
|
||||||
|
DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
|
||||||
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
|
|
||||||
|
|
||||||
if (e.type == EventType.DragPerform) {
|
if (e.type == EventType.DragPerform) {
|
||||||
DragAndDrop.AcceptDrag();
|
DragAndDrop.AcceptDrag();
|
||||||
|
graphEditor.OnDropObjects(DragAndDrop.objectReferences);
|
||||||
foreach (object droppedItem in DragAndDrop.objectReferences) {
|
|
||||||
graphEditor.DropItem(droppedItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EventType.MouseMove:
|
case EventType.MouseMove:
|
||||||
break;
|
break;
|
||||||
case EventType.ScrollWheel:
|
case EventType.ScrollWheel:
|
||||||
|
|||||||
@ -68,8 +68,9 @@ namespace XNodeEditor {
|
|||||||
return NodeEditorPreferences.GetTypeColor(type);
|
return NodeEditorPreferences.GetTypeColor(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DropItem(object droppedItem) {
|
/// <summary> Deal with objects dropped into the graph through DragAndDrop </summary>
|
||||||
target.OnDrop(droppedItem, NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition));
|
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>
|
/// <summary> Create a node and save it in the graph asset </summary>
|
||||||
|
|||||||
@ -81,12 +81,5 @@ namespace XNode {
|
|||||||
// Remove all nodes prior to graph destruction
|
// Remove all nodes prior to graph destruction
|
||||||
Clear();
|
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user