public void OnSceneGUI() { if (roadCreator == null) { roadCreator = (RoadCreator)target; } if (roadCreator.transform.hasChanged) { roadCreator.CreateMesh(); roadCreator.transform.hasChanged = false; } guiEvent = Event.current; Ray ray = HandleUtility.GUIPointToWorldRay(guiEvent.mousePosition); RaycastHit raycastHit; if (Physics.Raycast(ray, out raycastHit, 100f, ~(1 << roadCreator.settings.FindProperty("ignoreMouseRayLayer").intValue))) { hitPosition = raycastHit.point; if (guiEvent.control == true) { Vector3 nearestGuideline = Misc.GetNearestGuidelinePoint(hitPosition); if (nearestGuideline != Misc.MaxVector3) { hitPosition = new Vector3(nearestGuideline.x, hitPosition.y, nearestGuideline.z); } else { hitPosition = new Vector3(Mathf.Round(hitPosition.x), hitPosition.y, Mathf.Round(hitPosition.z)); } } if (guiEvent.type == EventType.MouseDown) { if (guiEvent.button == 0) { if (guiEvent.shift == true) { CreatePoints(); } } else if (guiEvent.button == 1 && guiEvent.shift == true) { RemovePoints(); } } else if (guiEvent.type == EventType.KeyDown && guiEvent.keyCode == KeyCode.S) { roadCreator.sDown = true; } else if (guiEvent.type == EventType.KeyUp && guiEvent.keyCode == KeyCode.S) { roadCreator.sDown = false; } else if (guiEvent.type == EventType.KeyDown && guiEvent.keyCode == KeyCode.A) { roadCreator.aDown = true; } else if (guiEvent.type == EventType.KeyUp && guiEvent.keyCode == KeyCode.A) { roadCreator.aDown = false; } if (roadCreator.transform.GetChild(0).childCount > 0 && roadCreator.transform.GetChild(0).GetChild(roadCreator.transform.GetChild(0).childCount - 1).GetChild(0).childCount == 2 && (guiEvent.type == EventType.MouseDrag || guiEvent.type == EventType.MouseMove || guiEvent.type == EventType.MouseDown)) { points = CalculateTemporaryPoints(hitPosition); } if (roadCreator.transform.childCount > 0) { Draw(hitPosition); } } if (Physics.Raycast(ray, out raycastHit, 100f, ~(1 << roadCreator.settings.FindProperty("roadLayer").intValue))) { hitPosition = raycastHit.point; if (guiEvent.control == true) { Vector3 nearestGuideline = Misc.GetNearestGuidelinePoint(hitPosition); if (nearestGuideline != Misc.MaxVector3) { hitPosition = new Vector3(nearestGuideline.x, hitPosition.y, nearestGuideline.z); } else { hitPosition = new Vector3(Mathf.Round(hitPosition.x), hitPosition.y, Mathf.Round(hitPosition.z)); } } if (guiEvent.shift == false) { MovePoints(raycastHit); } else { hitPosition = Misc.MaxVector3; MovePoints(raycastHit); } } if (guiEvent.type == EventType.MouseDown && guiEvent.button == 0 && Physics.Raycast(ray, out raycastHit, 100f, (1 << roadCreator.settings.FindProperty("roadLayer").intValue))) { hitPosition = raycastHit.point; if (guiEvent.control == true) { Vector3 nearestGuideline = Misc.GetNearestGuidelinePoint(hitPosition); if (nearestGuideline != Misc.MaxVector3) { hitPosition = new Vector3(nearestGuideline.x, hitPosition.y, nearestGuideline.z); } else { hitPosition = new Vector3(Mathf.Round(hitPosition.x), hitPosition.y, Mathf.Round(hitPosition.z)); } } roadCreator.SplitSegment(hitPosition, raycastHit); } GameObject.FindObjectOfType <RoadSystem>().ShowCreationButtons(); SceneView.currentDrawingSceneView.Repaint(); }