I’m trying to override the default drag and drop behavior inside the scene view for a prefab so the object is created through a factory instead of being directly instantiated. My idea is to intercept the drag and drop event in the OnSceneGUI method to introduce my behavior. Currently the method looks like this:
void OnSceneGUI() {
if (Event.current.type == EventType.DragExited) {
// i have to use a flag because the DragExited event is fired twice (¿?)
if(!_creating) {
WorldBuilder.Instance.AddPlatform( _myScript.length,_myScript.type);
_creating = true;
}
DragAndDrop.AcceptDrag();
Event.current.Use();
}
}
This creates the object via the Factory but it also instantiates a new one. I tried to clear the DragAndDrop.objectReferences array and add manually the factory object but it doesn’t work. Any idea on how i can achieve this?