ARCore的语义是否与ARKit的“guard let planeAnchor”相当?

问题描述 投票:1回答:1

我想知道ARCore / Kotlin中是否有类似的语义结构,如guard let / ARKit中的以下Swift声明?

let anchor: ARAnchor?

guard let planeAnchor = anchor as? ARPlaneAnchor else { 
    print("condition not met")
    return 
}
swift kotlin augmented-reality arkit arcore
1个回答
1
投票

我想我已经找到了使用Elvis运算符和安全转换运算符的ARCore的planeAnchor所需的语义:

public class CenterPosePlaneAnchor { ... }

val anchor: Anchor?
val info = "condition not met"

val planeAnchor = anchor as? CenterPosePlaneAnchor ?: return println(info)
© www.soinside.com 2019 - 2024. All rights reserved.