private void DrawControlPoints(ref bool elementClicked) { float buttonRadius = 0.5f; Handles.color = Color.blue; //Por cada stretch foreach (Vector2Int k in creator.stretches.Keys) { Stretch current = creator.stretches[k]; if (k == new Vector2Int(selectedControlPoint.x, selectedControlPoint.y)) { //current.ControlA is the selected one if (selectedControlPoint.z == 0) { Vector3 cAPos = current.ControlA; Quaternion cARot = Quaternion.LookRotation(Camera.current.transform.position - cAPos); EditorGUI.BeginChangeCheck(); Vector3 aPos = Handles.PositionHandle(cAPos, Quaternion.identity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(creator, "Move ControlA"); EditorUtility.SetDirty(creator); current.ControlA = aPos; if (current.anchorA.Mirror) { foreach (Stretch st in creator.GetAllStretchesFromNode(current.anchorA)) { if (st != current) { if (st.anchorA == current.anchorA) { st.ControlA = 2 * current.anchorA.transform.position - current.ControlA; } else if (st.anchorB == current.anchorA) { st.ControlB = 2 * current.anchorA.transform.position - current.ControlA; } } } } } Vector3 cBPos = current.ControlB; if (Handles.Button(cBPos, Quaternion.identity, buttonRadius, buttonRadius, Handles.SphereHandleCap)) { selectedControlPoint = new Vector3Int(k.x, k.y, 1); elementClicked = true; SceneView.RepaintAll(); } } //current.ControlB is the selected one else if (selectedControlPoint.z == 1) { Vector3 cAPos = current.ControlA; if (Handles.Button(cAPos, Quaternion.identity, buttonRadius, buttonRadius, Handles.SphereHandleCap)) { selectedControlPoint = new Vector3Int(k.x, k.y, 0); elementClicked = true; SceneView.RepaintAll(); } Vector3 cBPos = current.ControlB; EditorGUI.BeginChangeCheck(); Vector3 bPos = Handles.PositionHandle(cBPos, Quaternion.identity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(creator, "Move ControlB"); EditorUtility.SetDirty(creator); current.ControlB = bPos; if (current.anchorB.Mirror) { foreach (Stretch st in creator.GetAllStretchesFromNode(current.anchorB)) { if (st != current) { if (st.anchorA == current.anchorB) { st.ControlA = 2 * current.anchorB.transform.position - current.ControlB; } else if (st.anchorB == current.anchorB) { st.ControlB = 2 * current.anchorB.transform.position - current.ControlB; } } } } } } } else { Vector3 cAPos = current.ControlA; if (Handles.Button(cAPos, Quaternion.identity, buttonRadius, buttonRadius, Handles.SphereHandleCap)) { selectedControlPoint = new Vector3Int(k.x, k.y, 0); SceneView.RepaintAll(); } Vector3 cBPos = current.ControlB; if (Handles.Button(cBPos, Quaternion.identity, buttonRadius, buttonRadius, Handles.SphereHandleCap)) { selectedControlPoint = new Vector3Int(k.x, k.y, 1); SceneView.RepaintAll(); } } Handles.DrawLine(current.ControlA, current.anchorA.transform.position); Handles.DrawLine(current.ControlB, current.anchorB.transform.position); } }