public void OnSceneGUI() { Linkage3D links = (Linkage3D)target; if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(worldRay, out hitInfo)) { Joint3D selected; if (selected = hitInfo.collider.GetComponentInParent <Joint3D>()) { if (previousSelection == null) // first selection { previousSelection = selected; } else // second selection { if (previousSelection == selected) // selected again, undo selection { previousSelection = null; } else if (previousSelection.initialEdges.Contains(selected)) { Undo.RecordObject(previousSelection, "Remove Edge"); previousSelection.initialEdges.Remove(selected); PrefabUtility.RecordPrefabInstancePropertyModifications(previousSelection); } else if (selected.initialEdges.Contains(previousSelection)) { Undo.RecordObject(selected, "Remove Edge"); selected.initialEdges.Remove(previousSelection); PrefabUtility.RecordPrefabInstancePropertyModifications(selected); } else // didn't exist yet, add from previous to new { Undo.RecordObject(previousSelection, "Add Edge"); previousSelection.initialEdges.Add(selected); PrefabUtility.RecordPrefabInstancePropertyModifications(previousSelection); } previousSelection = null; } Event.current.Use(); } } } if (previousSelection) { Handles.DrawWireCube(previousSelection.transform.position, previousSelection.transform.lossyScale / 4f); } }
public Joint3D GetOtherJoint(Joint3D thisJoint) { if (thisJoint == j1) { return(j2); } else if (thisJoint == j2) { return(j1); } else { Debug.LogError("GetOtherJoint recieved an unconnected joint"); return(j1); } }