0

If I load an AR Game template it creates a file called Experience which is a Reality Composer file that you can reference in code. So you can see here:

let boxAnchor = try! Experience.loadBox()

enter image description here

Which is good... but how do I do this in my project? I created a Reality Composer file and added it to the project, but I cannot reference it?

enter image description here

enter image description here

And I cannot seem to find the additional link I need to add here to make it work? Do I have to call the file "Experience.rcproject", surely not?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
user3069232
  • 8,587
  • 7
  • 46
  • 87

1 Answers1

0

To load another Reality Composer scene (enumeration), you have to take four steps:

  1. Rename rook16.rcproject to Rook16.rcproject in Xcode Navigator pane.
  2. Consider Swift's enum naming convention. Write Rook16.loadBox().
  3. Select Rook16 in Navigator, go to Inspector (file tab) and tick a Target Membership.
  4. Restart your project in Xcode.

Here's the SwiftUI code:

func makeUIView(context: Context) -> ARView {
    let arView = ARView(frame: .zero)
    let rook16 = try! Rook16.loadBox()
    arView.scene.anchors.append(rook16)
    return arView
}
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220