Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Last active October 13, 2018 15:52
Show Gist options
  • Save SunXiaoShan/ba0627d7c829064b23da4a3f5bd1bede to your computer and use it in GitHub Desktop.
Save SunXiaoShan/ba0627d7c829064b23da4a3f5bd1bede to your computer and use it in GitHub Desktop.
override func viewDidLoad() {
super.viewDidLoad()
// 判斷是否裝置支援 ar face 功能
guard ARFaceTrackingConfiguration.isSupported else { fatalError() }
sceneView.delegate = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// 畫面顯示的時候,才會開啟功能
let configuration = ARFaceTrackingConfiguration()
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// 離開時則關閉
sceneView.session.pause()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment