This code works perfectly on a simple cube, however when loading a larger (250mb) .rcproject file I get the "Unexpectedly found nil while implicitly unwrapping an Optional value" error.
My code is as follows:
struct ARSandBox: UIViewRepresentable {
func makeUIView(context: Context) -> ARView {
var map: ModelEntity!
let arView = ARView(frame: .zero)
let delayTime = DispatchTime.now() + 3.0
let scene = try! TeaTestMap.loadMapScene()
map = scene.theMap!.children[0] as? ModelEntity
(Error is here at map.isEnabled)
map.isEnabled = false
arView.scene.anchors.append(scene)
DispatchQueue.main.asyncAfter(deadline: delayTime) {
map.isEnabled = true
}