为什么苹果的软件工程师删除了ARPlaneDetection
enum并改为生成了ARWorldTrackingConfiguration.PlaneDetection
struct?
是:
public enum ARPlaneDetection: UInt {
case .none
case .horizontal
}
现在:
public struct PlaneDetection: OptionSet {
public init(rawValue: UInt)
public var horizontal: ARWorldTrackingConfiguration.PlaneDetection { get }
public var vertical: ARWorldTrackingConfiguration.PlaneDetection { get }
}
与arkit中过时的枚举相比,new
PlaneDetection
struct有哪些优势? 最佳答案
这都是因为PlaneDetection
struct符合OptionSet
协议,该协议允许您为某些设置(如平面检测)设置多个选项。
let options: ARWorldTrackingConfiguration.PlaneDetection = [.horizontal, .vertical]
let options: ARWorldTrackingConfiguration.PlaneDetection = []
…这是
OptionSet
的优点,而仅使用枚举是不可能的。关于swift - ARKit - 为什么不再有'ARPlaneDetection'枚举?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55009346/