Docs for ".entry()" in EntityCommands is confusing / incomplete #16379
Labels
A-ECS
Entities, components, systems, and events
C-Docs
An addition or correction to our documentation
D-Straightforward
Simple bug fixes and API improvements, docs, test and examples
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
X-Uncontroversial
This work is generally agreed upon
How can Bevy's documentation be improved?
This relates to the new
.entry()
API for manipulating components. Specifically, the documentation doesn't make clear how to do a "get or insert" type of operation, which is what I think most users want. Specifically, the code example for.entry()
looks like this:This example seems to imply that if you want to modify a component in place, or create a new component if it does not already exist, then you have to specify the component values twice: once for the "already exists" case, and once for the "create new" case. In this example the component only has one field, but for something like
Node
this would be onerous. My mistaken understanding caused me to avoid using this API for a long time - thinking it wasn't that useful - until someone on Discord informed me about the.or_default()
option.My suggestion is that the docs for
.entry()
should include an example which is less artificial, and more like a typical use case: "get the component if it exists, create it if it doesn't, and then let me specify the parameters one time."The text was updated successfully, but these errors were encountered: