Search Unity

Is there a way to quickly see the index of a vert on a SkinnedMesh in the Editor?

Discussion in 'Editor & General Support' started by Ony, Aug 7, 2019.

  1. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    I'm doing some work where I need to place things at specific verts, and I am wondering if there's some quick way to see the index number of a chosen vert in the Editor.

    The method I did earlier today basically casts a ray out from every vert on the (Skinned) mesh, then when one of those rays intersects with my "vert finder" object (has a collider on it) that I move around in the Editor, it logs the vert index number the "vert finder" object is intersecting. That gives me the vert index number I need. It's messy but it works (not using it in builds, just during this part).

    So, aside from doing what I'm already doing, is there an easy way to just pick a vert on a SkinnedMesh and get its index number without casting a bunch of rays and all that jazz?

    I've tried the triangle hit thing from a camera but it doesn't seem to want to work with Skinned Meshes. It works with others, just not Skinned.

    Thanks ahead of time if anyone knows one.
     
    Last edited: Aug 7, 2019
  2. Deleted User

    Deleted User

    Guest

    I have an idea:
    I would transform all the vertices into (Editor) camera space. This way, a distance check with the mouse cursor is merely a comparison of the x and y screen space axis. You could transform them and save the result in a dictionary where the key is the new position and the value is its index. You can do this in a custom editor or whatever way you like, a "capture verts" button for example. If you then draw an overlay for the vertex you're closest to you know exactly which one you're mouse is closest to and with a little editor label you can show the index there.
     
    Ony likes this.
  3. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    Hmmm, yeah, that sounds promising, thanks! I'll give it a shot.