protected override void Cast(Event @event, Ray ray, out Vector3 position, out string error, out Plane plane) { RaycastHit hit; if (Physics.Raycast(ray, out hit)) { position = hit.point; plane = new Plane(hit.normal, hit.point); error = null; } else { error = BGSceneViewOverlay.ToError("No mesh (or collider) to snap a point to!") + " \r\n Use Ctrl+Shift+Click to spawn a point at the distance,\r\n which is set in settings"; position = ray.GetPoint(10); plane = new Plane(); } }
protected override void Cast(Event @event, Ray ray, out Vector3 position, out string error, out Plane plane) { var curve = overlay.Editor.Curve; Get2DPlane(out plane, curve); float distance; if (!plane.Raycast(ray, out distance)) { error = BGSceneViewOverlay.ToError("Curve is in 2D mode! \r\n Curve's plane does not intersect with the current point.") + "\r\nUse Ctrl+Shift+Click to spawn a point at the distance,\r\n which is set in settings"; position = ray.GetPoint(10); } else { error = null; position = ray.GetPoint(distance); } }