【发布时间】:2021-11-23 04:34:11
【问题描述】:
我想在 Entity 不仅已加载回合也已成功附加到 AnchorEntity
时运行一些函数现在我的实体正在异步加载。
func addModel(to planeAnchor: AnchorEntity) {
Entity.loadAsync(named: "SomeUSDZModel")
.sink { completion in
switch completion {
case .finished:
print("Ok")
case .failure(let error):
print(error.localizedDescription)
}
} receiveValue: { model in
// Entity should be added before the animation is started.
planeAnchor.addChild(model)
if let walkingAnimation = model.availableAnimations.first {
model.playAnimation(walkingAnimation.repeat(duration: .infinity),
transitionDuration: 1.25,
blendLayerOffset: 0,
separateAnimatedValue: false,
startsPaused: false)
}
self.model = model
}
.store(in: &subscriptions)
doSomething()
}
方法 doSomething() 过早触发。我想通过一些条件检查来触发它。
【问题讨论】:
标签: swift arkit combine realitykit