Created
December 3, 2018 06:53
-
-
Save michaelevensen/4e90f8f051d12a905a0dee7b8a06382c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create TapGesture Recognizer | |
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap(rec:))) | |
//Add recognizer to sceneview | |
sceneView.addGestureRecognizer(tapRec) | |
//Method called when tap | |
@objc func handleTap(rec: UITapGestureRecognizer){ | |
if rec.state == .ended { | |
let location: CGPoint = rec.location(in: sceneView) | |
let hits = self.sceneView.hitTest(location, options: nil) | |
if !hits.isEmpty{ | |
let tappedNode = hits.first?.node | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment