Hello, here is my coding for the immersive view of Xcode Beta SwiftUI VisionPro when I first create a new project.
struct ImmersiveView: View {
@Environment(\.openWindow) var openWindow
var body: some View {
RealityView { content in
// Add the initial RealityKit content
if let immersiveContentEntity = try? await Entity(named: "Immersive", in: realityKitContentBundle) {
content.add(immersiveContentEntity)
// Add an ImageBasedLight for the immersive content
guard let resource = try? await EnvironmentResource(named: "ImageBasedLight") else { return }
let iblComponent = ImageBasedLightComponent(source: .single(resource), intensityExponent: 0.25)
immersiveContentEntity.components.set(iblComponent)
immersiveContentEntity.components.set(ImageBasedLightReceiverComponent(imageBasedLight: immersiveContentEntity))
// Put skybox here. See example in World project available at
// https://developer.apple.com/
}
}
.onLongPressGesture {
openWindow(id:"A")
}
}
}
I have just added a tap gesture to the immersive view because all I want is to test and see if it opens a window by tapping anywhere on the screen in the simulator. Unfortunately, the tapping does not work but the tap gestures works in a normal window group. Please explain to me why tap gestures don't work in immersive views? I need some help. If gestures do work then can you send me the updated code with the working gesture. Thank you.