Get the index of the currently selected HandleUtility.FreeMoveHandle in Scene View
I'm using FreeMoveHandles to modify the vertices of a 2D mesh in my scene view. Using these handles to modify the mesh works perfectly, but I now want to be able to figure out the index of the handle that is currently selected. I can't find anything within the Handles or the HandleUtility classes that seem like they could help me though and I'm at a bit of a dead end.
Here's my code for the creation and use of the FreeMovementHandles in an OnSceneGUI function:
for(int i = 0; i < generatedMesh.verts.Length; i++)
{
//current position of the vert
Vector3 oldPoint = generatedMesh.verts[i].ToVector3();
//new position of the vert assign through moving a handle
Vector3 newPoint = Handles.FreeMoveHandle(generatedMesh.verts[i].ToVector3(),
Quaternion.identity,
0.2f, Vector3.one,
Handles.DotCap);
//if the handle has changed the position of any vert, update that position
if(oldPoint != newPoint)
{
generatedMesh.verts[i] = newPoint;
}
}
If anyone has any ideas or could point me in a direction it would be very much appreciated.
Thanks, Matt
I can only come up with the hacky version:
if(oldPoint != newPoint)
{
generated$$anonymous$$esh.verts[i] = newPoint;
last$$anonymous$$ovedIndex = i;
}
I think that's your best bet, afaik the Handles class does not store any history.
Cheers. I ended up just creating a function that found the closest vert position to the mouseclick position and subverting the handles.
Your answer
![](https://koobas.hobune.stream/wayback/20220612044713im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
IndexOutOfRangeExeption! This doesent even affect my gameplay, it just is there to be annoying! 1 Answer
Toggle Button: hope it toggle once but it toggle many times 1 Answer
Locate _MainTex from a public shader and assign to instantiated prefab for GUI 1 Answer
Update and Get PlayerPrefs during runtime? 0 Answers
NullReferenceException on a public image, that was declared 0 Answers