0
votes

Setup:

  • For displaying 3D elements Scenekit is used. For 2D elements Spritekit.
  • SceneView() is used to display a scene.
  • An SCNScene and an SCNNode for the camera are given.

Goal:

Now I want to put a 2D overlay over the SCNScene. Previously this could be achieved using the overlaySKScene property of the SCNView. But now that in SwiftUI only the scene and camera are given I wonder how this can be achieved.

Thanks already in advance.

2

2 Answers

1
votes

The SpriteKit overlay is not supported by SceneView in iOS 14.

0
votes

If you want a SpriteKit scene layered on top of an SCNScene, you can do it with SwiftUI, like this:

struct MyView: View {
    @State private var 2dscene = MyScene()
    @State private var 3dScene = SCNScene(named: "MyFile")

    var body: some View {
       ZStack {
           SceneView(scene: 3dScene)
           SpriteView(scene: 2dscene)
       }
    }
}