My Reality-kit progressive app has a Large cube in the scene that acts as a Skybox. I can use the digital crown to fade the skybox in and out. However if I go back home screen and re-enter my app it acts as if it’s ran in shared mode and ignores the unbounded volume instead only rendering the bounded volumes. When I use the digital crown it fades in the Vision OS system skybox and not the one set in my app. The only way to get it working again is to force shut down the app.
Is there a way I can force the app to always run in exclusive mode? I believe this will solve the issue.
Hi there! This is a known issue with apps that start up into an immersive space. The OS dismisses your immersive space when the user presses the home button, but it expects the app to explicitly re-open the space later on. In the case of a Swift app, you would call openImmersiveSpace
when you get a notification that your app returns to the foreground, and we need to implement that somewhere in Unity.
You should see your immersive space come back if you explicitly select the app from the home screen (rather than just dismissing it). Otherwise, you might be able to get the desired result if you pick up on some input in the bounded volume(s) and use that to trigger a change to the unbounded volume camera (like quickly disabling and re-enabling it). That will kick Unity into thinking it has to close and open the immersive space, but it’s pretty kludgy.
We’re working on a fix, and I’ll update this thread when we have something to share.
Hello, I implemented the openImmersiveSpace
approach by editing the swift code directly and I managed to fix my issue.
After building the app from unity and opening it in Xcode, I navigated to the UnityPolySpatialApp
file under the MainApp
Folder. I then went to the following section:
var body: some Scene {
mainScene
}
I added an OnChangeEvent to it as follows:
var body: some Scene {
mainScene
.onChange(of: scenePhase) { newPhase in
if newPhase == .active {
Task {
await dismissImmersiveSpace()
await openImmersiveSpace(id: "Unbounded")
}
}
}
}
Basically whenever the mainScene is active i.e refocused, I hide the immersion space then reopen it. At the top of the class, I added the scenePhase Variable as follows:
struct UnityPolySpatialApp: App, PolySpatialWindowManagerDelegate {
@UIApplicationDelegateAdaptor
var delegate: UnityPolySpatialAppDelegate
@Environment(\.openWindow) var openWindow
@Environment(\.dismissWindow) var dismissWindow
@Environment(\.openImmersiveSpace) var openImmersiveSpace
@Environment(\.dismissImmersiveSpace) var dismissImmersiveSpace
@Environment(\.scenePhase) var scenePhase
Finally when calling the openImmersiveSpace
space method I am passing it the ID of my unbounded volume. I got this ID from my UnityVisionOSSettings
file in the same directory.
@SceneBuilderaz
var mainScenePart0: some Scene {
ImmersiveSpace(id: "Unbounded", for: UUID.self) { uuid in
PolySpatialContentViewWrapper(minSize: .init(1.000, 1.000, 1.000), maxSize: .init(1.000, 1.000, 1.000))
... rest of the code ...
}