My visionOS app has a RealityView with an attachment containing SwiftUI controls, and occasionally the controls in the attachment don't respond to user interaction.
Is this a known issue?
Is there a workaround?
Are RealityView attachments only intended to be output only?
Using visionOS 1.0 beta 3 (Xcode 15 beta 8), I've reproduced this problem with a small standalone Xcode project. I submitted the issue as FB13143132 with lovingly hand-crafted artisan repro steps. The Xcode project is also available at https://github.com/drewolbrich/AttachmentControls
Thank you for investigating this issue.
Screenshot my use case:
I have added an attachments closure in an RealityView as outlined in WWDC session "Enhance your spatial computing app with RealityKit" but it's not showing up - neither in Xcode preview window nor in Vision Pro simulator. I have used example code 1:1, however, I had to load the entity async with "try? await" to satisfy the compiler. Any help is appreciated, thx in advance!
Is this a know bug or is there a funamental misunderstanding on my part?
In the screenshot I've attached below I would expect the blue box to be perpendicular to the floor. It is the yAxisEntity in my code which I instatniate with a mesh of height 3. Instead it runs parallel to the floor what I'd expect to the z axis.
Here is my code
struct ImmerisveContentDebugView: View {
@Environment(ViewModel.self) private var model
@State var wallAnchor: AnchorEntity = {
return AnchorEntity(.plane(.vertical, classification: .wall, minimumBounds: SIMD2<Float>(0.1, 0.1)))
}()
@State var originEntity: Entity = {
let originMesh = MeshResource.generateSphere(radius: 0.2)
return ModelEntity(mesh: originMesh, materials: [SimpleMaterial(color: .orange, isMetallic: false)])
}()
@State var xAxisEntity: Entity = {
let line = MeshResource.generateBox(width: 3, height: 0.1, depth: 0.1)
return ModelEntity(mesh: line, materials: [SimpleMaterial(color: .red, isMetallic: false)])
}()
@State var yAxisEntity: Entity = {
let line = MeshResource.generateBox(width: 0.1, height: 3, depth: 0.1)
return ModelEntity(mesh: line, materials: [SimpleMaterial(color: .blue, isMetallic: false)])
}()
@State var zAxisEntity: Entity = {
let line = MeshResource.generateBox(width: 0.1, height: 0.1, depth: 3)
return ModelEntity(mesh: line, materials: [SimpleMaterial(color: .green, isMetallic: false)])
}()
var body: some View {
RealityView { content in
content.add(wallAnchor)
wallAnchor.addChild(originEntity)
wallAnchor.addChild(xAxisEntity)
wallAnchor.addChild(yAxisEntity)
wallAnchor.addChild(zAxisEntity)
}
}
}
And here is what the simualtor renders