Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Connect two waypoints in scene view using drag and drop

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

  1. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    145
    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! :)