无法获取位置Inview:对于尝试检索位置时,对于这种类型的NSTouch断言错误



我正在尝试在用户单击特定的scnnode后试图检索鼠标位置。我最终想执行一项热门测试,以确定单击哪些SCNNODE。我有以下代码,但是一旦运行项目,我就会遇到一个断言错误:"无法获得位置Inview:对于这种类型的NSTOUCH"。任何帮助将不胜感激。

override func touchesBegan(with event: NSEvent) {
    let touch = event.touches(for: self.view)
    if #available(OSX 10.12.2, *) {
        let location = touch.first?.location(in: self.view)
        let hitResults = sceneView.hitTest(location!, options: nil)
    } else {
        // Fallback on earlier versions
    }
}

-locationInView:仅适用于type NSTouchTypeDirect的触摸。如果您的Mac带有触摸栏,按下它将导致屏幕上没有位置的类型NSTouchTypeIndirect的事件。

相关内容

最新更新