Search Unity

Place Points of Mouse Position along Handles.DrawLine

Discussion in 'Editor & General Support' started by Subliminalman, Apr 17, 2017.

  1. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    I'm trying to create a mesh creation tool where you can right-click on the line to add another vertex. I am having trouble transforming from screen space to the world space and injecting the point in the correct space in my line segment list.

    This is essentially what I want to happen.


    I'm currently trying to get the position it with this code but it keeps sending me wrong values something like (0,0,0) when I would be expecting something like (0.5f, 0f, 0f)

    Vector3 pos = HandleUtility.ClosestPointToPolyLine(lvlMesh.GetVertices());