Post

Replies

Boosts

Views

Activity

Reply to How can I pinch to open a menu in VisionOS simulator?
This is my main app coding with all the window groups. I am trying to ensure that the Video window opens when I tap anywhere on the screen in the immersive view space named "Immersive Space". var body: some Scene { WindowGroup(id: "Begin") { MainMenuView() } WindowGroup(id: "Navigate") { MapView() } WindowGroup(id: "Video") { VideoView() } ImmersiveSpace(id: "ImmersiveSpace") { ImmersiveView() }.immersionStyle(selection: .constant(.full), in: .full) } } Here is my VideoView coding which displays the back button. This is the view I want to open in the window of the visionOS simulator when I tap anywhere on the screen. @Environment(\.dismiss) private var dismiss var body: some View { VStack { Button("Back") { dismiss() } } .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom) .background(Color.white) } } Is this coding knowledge enough for you to help me? Thank you.
Sep ’23
Reply to How can I pinch to open a menu in VisionOS simulator?
// Get the video URL //Create Entity for the video let videoEntity = Entity() //Search for video in paths guard let url = Bundle.main.url(forResource: "harmandir-sahib-sarovar", withExtension: "mp4") else { fatalError("Video was not found!") } //create a simple AVPlayer let asset = AVURLAsset(url: url) let playerItem = AVPlayerItem(asset: asset) let player = AVPlayer() //create a videoMaterial let material = VideoMaterial(avPlayer: player) //Made a Sphere with the videoEntity and asign the videoMaterial to it videoEntity.components.set(ModelComponent(mesh: .generateSphere(radius: 1E3), materials: [material])) //adjust the properties of the videoEntity(Sphere) if needed videoEntity.scale = .init(x: 1, y: 1, z: -1) videoEntity.transform.translation += SIMD3<Float>(0.0, 10.0, 0.0) let angle = Angle.degrees(90) let rotation = simd_quatf(angle: Float(angle.radians), axis: .init(x: 0, y: 0, z: 0)) videoEntity.transform.rotation = rotation //add VideoEntity to realityView content.add(videoEntity) //start the VideoPlayer player.replaceCurrentItem(with: playerItem) //set the actionAtItemEnd property to .none player.actionAtItemEnd = .none //subscribe to the notification and seek back to start NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: player.currentItem, queue: .main) { _ in player.seek(to: CMTime.zero) player.play() } player.play() } .contentShape(Rectangle()) .onTapGesture { Task { openWindow(id: "Video") } } } } } I did create a WindowGroup of that id Video to open a window with a back button. But unfortunately I have tried loads of methods especially with the .onTapGesture and when I try to tap anywhere on the screen in the VisionOS simulator but it still would not open the window. What I really want is to enable tap gestures in the simulator so that it can open the window by a single touch anywhere on the 360 panorama video (reality view). I do not know what I have been doing wrong. I really need some help. Thank you.
Sep ’23