I am wondering how I can edit the func session(_ session: ARSession, didAdd anchors: [ARAnchor]) in the arView.session.delegate. I would like to run a function when the image is recognized.
Any and all guidance is appreciated! Thanks in advance.
Code Block swift struct ARViewWrapper: UIViewRepresentable { let title: String typealias UIViewType = ARView func makeUIView(context: Context) -> ARView { print("detected?") let arView = ARView(frame: .zero, cameraMode: .ar, automaticallyConfigureSession: true) let target = AnchorEntity(.image(group: "AR Resources", name: "qr1")) arView.scene.anchors.append(target) addARObjs(anchor: target, title: title, planeColor: .blue) return arView } func updateUIView(_ uiView: ARView, context: Context) { print("update!") return() } }
Any and all guidance is appreciated! Thanks in advance.
Hello,
You should create a Coordinator object to act as your ARSessionDelegate. See the Interfacing with UIKit SwiftUI Tutorial for an example that uses a Coordinator.
You should create a Coordinator object to act as your ARSessionDelegate. See the Interfacing with UIKit SwiftUI Tutorial for an example that uses a Coordinator.