Is the Bounded Volume Window ID Exposed Within SwiftUI?

Hi, I am using some of the new VisionOS 2 and Polyspatial 2.0 functions for my project, such as .defaultWindowPlacement.
I would like to use the WindowGroup IDs that exist within some SwiftUI Scene which pertain to the Bounded Volume. It should exist because the Bounded Volume has the pinch borders that are connected to SwiftUI, as well as events that Unity can listen in, such as WindowEvents. Are these currently exposed on the latest version of Polyspatial 2.0?
Thanks.

1 Like

Hi,

Just to get more clarification here - are you looking for the WindowGroup IDs that are generated and used when you build PolySpatial to VisionOS?

There’s no way to programmatically obtain those, but after you make a PolySpatial Xcode build, you can take a peak into UnityVisionOSSettings.swift in the build folder. That contains some of the WindowGroup definitions and IDs that will be used in your project at runtime. You should be able to just call openWindow with that id if you want to open your own windows, or you can modify those WindowGroup definitions with .defaultWindowPlacement yourself - just be aware making a new build will re-generate UnityVisionOSSettings.swift and might blow away any changes you make.

Hope that helps, and let me know if that answered your question!

1 Like

This helps a lot. I can see if I can hack around with this ID. I only have one issue from your response. I cannot find any reference to UnityVisionOSSettings.swift inside either the XCode project or Unity project. This is the only reference I can find to it:


Is there a particular Polyspatial Build process that I might be missing? Or did you mean another file.
Thanks!

Hi,

It should be under path Unity-VisionOS/MainApp/UnityVisionOSSettings.swift. If you have default key binds, you might be able to do cmd + shift + o (Mac keyboard shortcuts - Apple Support) and type in UnityVisionOSSettings to find it fast.

1 Like

I found it! Thanks. For anyone looking at this thread in the future, we have a few bounded volumes. They have generic names that seem to not change too drastically:

@SceneBuilder
    var mainScenePart0: some Scene {

                    WindowGroup(id: "Bounded-0.500x0.500x0.500", for: UUID.self) { uuid in
                        PolySpatialContentViewWrapper(minSize: .init(0.500, 0.500, 0.500), maxSize: .init(0.500, 0.500, 0.500))
                            .environment(\.pslWindow, PolySpatialWindow(uuid.wrappedValue, "Bounded-0.500x0.500x0.500", .init(0.500, 0.500, 0.500)))
                        KeyboardTextField().frame(width: 0, height: 0).modifier(LifeCycleHandlerModifier())
                    } defaultValue: { UUID() } .windowStyle(.volumetric).defaultSize(width: 0.500, height: 0.500, depth: 0.500, in: .meters).windowResizability(.contentSize) .upperLimbVisibility(.visible) .volumeWorldAlignment(.gravityAligned)
                    WindowGroup(id: "Bounded-1.000x1.000x1.000", for: UUID.self) { uuid in
                        PolySpatialContentViewWrapper(minSize: .init(1.000, 1.000, 1.000), maxSize: .init(1.000, 1.000, 1.000))
                            .environment(\.pslWindow, PolySpatialWindow(uuid.wrappedValue, "Bounded-1.000x1.000x1.000", .init(1.000, 1.000, 1.000)))
                        KeyboardTextField().frame(width: 0, height: 0).modifier(LifeCycleHandlerModifier())
                    } defaultValue: { UUID() } .windowStyle(.volumetric).defaultSize(width: 1.000, height: 1.000, depth: 1.000, in: .meters).windowResizability(.contentSize) .upperLimbVisibility(.visible) .volumeWorldAlignment(.gravityAligned)
                    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))
                            .environment(\.pslWindow, PolySpatialWindow(uuid.wrappedValue, "Unbounded", .init(1.000, 1.000, 1.000)))
                            .onImmersionChange() { oldContext, newContext in
                                PolySpatialWindowManagerAccess.onImmersionChange(oldContext.amount, newContext.amount)
                            }
                        KeyboardTextField().frame(width: 0, height: 0).modifier(LifeCycleHandlerModifier())
                    } defaultValue: { UUID() }  .upperLimbVisibility(.visible)
                    .immersionStyle(selection: .constant(.automatic), in: .automatic)

In this case, we can possibly OpenWindow(“Bounded-1.000x1.000x1.000”)