Skip to content

Best way to expose a getter/setter for a component of a child of an entity? #18045

Answered by Henauxg
elenakrittik asked this question in Q&A
Discussion options

You must be logged in to vote

If I understand your question correctly, you're more interested in a way to hide your custom Entity hierarchy between your two text entities ?

You could have a look at the upcoming entity relationships coming in the soon to be released version 0.16.0 (#17398).

Or you could just DIY store a component on your TextInput entity storing a reference to the Text display entity, something like:

#[derive(Component)]
struct TextRef(pub Entity);

This way your hierarchy does not matter and can freely change without breaking any user-side code. You just query the TextRef component and access the Text component of the referenced entity.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@elenakrittik
Comment options

Comment options

You must be logged in to vote
1 reply
@elenakrittik
Comment options

Answer selected by elenakrittik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants