Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Connect two waypoints in scene view using drag and drop

Discussion in 'Extensions & OnGUI' started by nicmarxp, Aug 7, 2018.

  1. nicmarxp


    Dec 3, 2017
    I’m making a waypoint system, where each node has one or more previous and next nodes which makes it possible for the paths to branch. Currently it’s a list of GameObjects, one for previous, and one for next nodes. This is manually set up and it would be really nice to be able to just connect them by dragging in the scene view.

    What I think I want to do first, is make an editor script, so when I select a node, a red (previous) and a green (next) handle is shown.

    The challenge here is to drag from one of the handles and see a visual red/green line connected to the mouse, and then I can release it on another node, and it will add the source nodes to the target list and the other way around. If I release it somewhere else, nothing happens.

    Should I use raycast (screenpointtoworld?) continuosly below the mouse and search for a node, and then somehow highlight it, to visualize that I can drop it?

    The nodes have rectangular colliders, which I guess helps with raycasting.

    I’d be happy for feedback before I start coding this, to see if it’s plausable. I haven’t found any other drag-drop-with-lines features so far, but it seems that it should work.

    Thanks! :)