I have the same problem placing a toolbarItem in TextEditor. Also need it to work on iOS 15, so I cannot use NavigationStack. Any workaround?
TextEditor(text: $text)
.padding(.all)
.padding(.vertical, -8)
.padding(.horizontal, -5)
.focused($focusedField, equals: .textArea)
.toolbar {
ToolbarItem(placement: .keyboard) {
HStack{
Spacer()
Button("_done") {
focusedField = nil
}
}
}
}
.disabled(disabled)
Post
Replies
Boosts
Views
Activity
Well I think I found the piece we were missing. You have to make the session aware of the newly created anchor, like this:
arView.session.add(anchor: arAnchor)
I hope this solves your problem
So the full code:
func place(_ modelEntity: ModelEntity, in arView: CustomARView, for anchor: GARAnchor) {
let clonedEntity = modelEntity.clone(recursive: true)
clonedEntity.generateCollisionShapes(recursive: true)
print("Size: \(clonedEntity.visualBounds(relativeTo: .none))")
if(anchor.hasValidTransform) {
let arAnchor = ARAnchor(transform: anchor.transform)
arView.session.add(anchor: arAnchor)
let anchorEntity = AnchorEntity(anchor: arAnchor)
anchorEntity.addChild(clonedEntity)
arView.scene.addAnchor(anchorEntity)
print("Anchor place for: \(anchor.transform)")
} else {
print("Not valid transform")
}
}
Well I think I found the piece we were missing. You have to make the session aware of the newly created anchor, like this:
arView.session.add(anchor: arAnchor)
Hi Franklan010,
Any progress on this matter? I'm stuck on the very same exact point. Well, my problem is slightly different: I create the garAnchor with (the newly added) createAnchorOnTerrain; the anchor is created, but it seems to have an invalid transform.
Id be very greatful if you can help me on this!
Thanks in advance!