I have a Reality composer project that contains a text entity:
'' : ScreenObject, children: 1
⟐ Transform
⟐ SynchronizationComponent
⟐ AnchoringComponent
▿ '' : AnchorEntity, children: 2
⟐ Transform
⟐ SynchronizationComponent
⟐ AnchoringComponent
▿ '' : Entity, children: 3
⟐ Transform
⟐ SynchronizationComponent
▿ 'textE' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'EE1CDC29-88C9-4144-80EB-A2D03F51A8AC' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'simpBld_root' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'simpBld_text' : ModelEntity
⟐ Transform
⟐ ModelComponent
⟐ SynchronizationComponent
▿ 'imageE' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'simpBld_root' : ModelEntity
⟐ Transform
⟐ ModelComponent
⟐ SynchronizationComponent
▿ 'screenE' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'simpBld_root' : ModelEntity
⟐ Transform
⟐ ModelComponent
⟐ CollisionComponent
⟐ SynchronizationComponent
▿ 'Ground Plane' : Entity
⟐ PhysicsBodyComponent
⟐ Transform
⟐ CollisionComponent
⟐ SynchronizationComponent
After studying all sorts of tutorials, Apple Docs and Stackoverflow queries (with answers from Andy Jazz for example), I have access to some properties of the textE entity in my project:
override func viewDidLoad() {
super.viewDidLoad()
if let screenAnchor = try? Experience.loadScreenObject() {
print(screenAnchor)
let textEntity = screenAnchor.findEntity(named: "textE")
print(textEntity!.scale)
arView.scene.anchors.append(screenAnchor)
}
}
But there does not seem to a property for the text content. I also found teaching material using child chaining to get to the content part for the text - BUT - I cannot find teaching material to teach me about this child chaining process: How many children do I need to come to my text entity and why? When do I need 0 or 1 for [children] and why?
If someone could point me to some teaching material and how it relates to my scenario above, I would be most grateful!
Ok, I found the answer to this one. Some of related, but old, answers clearly stated that the scene is using an enum structure. That helped me to learn about hierarchies in enum structures.
All the information I needed is then actually in the output from the ScreenObject enum hierarchy, that I posted.
If there is only 1 child for a step in the hierarchy then I use children[0] to get down to the next level; if there are 2 children, then I have to access the one I need with either children[0] or children[1] etc.
I got myself also confused by trying out old answers to similar questions but my scene hierarchy was of course different, or the entity structure in reality composer has changed too.
So now I was just checking my printed hierarchy and carefully went down the tree until I came to the components node and then could access the ModelComponent.
Most likely that is trivial to most and embarrassing for me, but I post the answer in case there is another beginner in this field.