英文:
visionOS - Can you use a RealityView outside of an ImmersiveSpace?
问题
I have a visionOS app that supports both a WindowGroup and an ImmersiveSpace.
import SwiftUI
@main
struct VisionApp: App {
@State var immersionStyle: ImmersionStyle = .mixed
var body: some Scene {
WindowGroup {
ContentView()
}
ImmersiveSpace(id: "MySpace") {
MySpace()
}
.immersionStyle(selection: $immersionStyle, in: .mixed)
}
}
The window is a normal window. I am able to load up my SwiftUI views and also use other apps like Safari. I have a button to launch the ImmersiveSpace.
The ImmersiveSpace is not fully immersive. There are a few models and particle emitters, but otherwise you can still see all of your actual surroundings. I can still see my app's window, but unfortunately it appears that when you launch an ImmersiveSpace it causes all other apps to be backgrounded.
I've tried putting RealityView inside a WindowGroup, but it does not seem to work:
WindowGroup {
RealityView {
/// ...
/// ...
}
I suspect this is intended behavior and a limitation of ImmersiveSpace, but I am asking to be sure.
英文:
I have a visionOS app that supports both a WindowGroup and an ImmersiveSpace.
import SwiftUI
@main
struct VisionApp: App {
@State var immersionStyle: ImmersionStyle = .mixed
var body: some Scene {
WindowGroup {
ContentView()
}
ImmersiveSpace(id: "MySpace") {
MySpace()
}
.immersionStyle(selection: $immersionStyle, in: .mixed)
}
}
The window is a normal window. I am able to load up my SwiftUI views and also use other apps like Safari. I have a button to launch the ImmersiveSpace.
The ImmersiveSpace is not fully immersive. There are a few models and particle emitters, but otherwise you can still see all of your actual surroundings. I can still see my app's window, but unfortunately it appears that when you launch an ImmersiveSpace it causes all other apps to be backgrounded.
I've tried putting RealityView inside a WindowGroup, but it does not seem to work:
WindowGroup {
RealityView {
/// ...
/// ...
}
I suspect this is intended behavior and a limitation of ImmersiveSpace, but I am asking to be sure.
答案1
得分: 1
你可以在常规窗口和音量中都使用 RealityView。我刚刚尝试将 RealityView 放置在这两者中的每一个,都可以正常工作。也许可以发布更多你的代码?
英文:
You can use a RealityView in both a regular window and a volume. I just tried placing a RealityView in each of these, and it works fine. Maybe post more of your code?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论