While there are many ways of doing it, here’s how I would handle it. This example only covers the onDrop update. (if I find the time later on, I’ll try to post the onMouseMove
solution as well).
- in the waypoint actor, the widget is going to bind an Event Dispatcher to this custom event:
- in the waypoint widget; an Event Dispatcher taking a location vector and an additional bool keeping track of whether we need to spawn an actor for this widget:
- when dropped, the payload is added to the canvas, we keep a local reference for later:
- the rest of the same graph:
- dropping for the first time, reparents the widget and spawns a new actor, further drag & drops simply reposition the existing one:
But again, I can think of a number of ways of handling it. If you’re ok with hard references, you can create one in the widget and feed it the spawned actor.