// // YellowSpheresImmersiveView.swift // TestFlickeringBetweenImmersiveSpaces // import SwiftUI import RealityKit import RealityKitContent struct YellowSpheresImmersiveView: View { @Environment(AppModel.self) var appModel var body: some View { RealityView { content, attachments in // Add the initial RealityKit content if let immersiveContentEntity = try? await Entity(named: "YellowSpheres", in: realityKitContentBundle) { immersiveContentEntity.position = [0.0, 0.1, -2.5] content.add(immersiveContentEntity) guard let showRedSpheresButton = attachments.entity(for: "ShowRedSpheres") else { assertionFailure("missing attachment") return } showRedSpheresButton.position = [0.0, 1, -2.5] showRedSpheresButton.scale = scaleForAttachements content.add(showRedSpheresButton) } } update: { content, attachments in } placeholder: { ProgressView() } attachments: { Attachment(id: "ShowRedSpheres") { Button { // dismissCurrnt and open next immersive space appModel.immersiveSpaceID = "RedSpheres" } label: { Text("Show RedSpheres") } } } } } #Preview(immersionStyle: .mixed) { YellowSpheresImmersiveView() .environment(AppModel()) }