Hey everybody,
I am quite new to developing on ios specifically in the AR section, and I have been struggling through documentation and can't find an answer for loading in reality composer pro scenes into an ios app. There is a good amount of documentation on loading it into a visionOS app but it I haven't found it totally applicable. In this code block below I have been able to get my reality composer scene loaded, but I am wanting the added functionality of reality composer pro when developing my scenes and can't figure out how to get those to show up. How would I edit this code to load my reality composer pro scene? My reality composer pro project came over to xcode as Package.realitycomposerpro when I drag and dropped it in, but I don't know how I'd access a scene in it and the specific objects in that scene for ios use. Thanks in advance!
import RealityKit
struct ContentView: View {
var body: some View {
ARViewContainer().edgesIgnoringSafeArea(.all)
}
}
struct ARViewContainer: UIViewRepresentable {
func loadRealityComposerScene(filename: String, fileExtension: String, sceneName: String) -> (Entity & HasAnchoring)? {
guard let realitySceneURL = Bundle.main.url(forResource: filename, withExtension: fileExtension) else {
return nil
}
let loadedAnchor = try? Entity.loadAnchor(contentsOf: realitySceneURL)
return loadedAnchor
}
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
// Load the AR Scene from ACT2.reality
guard let anchor = loadRealityComposerScene(filename: "ACT2", fileExtension: "reality", sceneName: "Scene1") else {
print("Failed to load the anchor from ACT2.reality")
return arView
}
arView.scene.addAnchor(anchor)
// Visualize Collisions for Debugging
arView.debugOptions.insert(.showPhysics)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {}
}
#Preview {
ContentView()
}