Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View all resources with World.resources() #1891

Closed
alice-i-cecile opened this issue Apr 12, 2021 · 7 comments
Closed

View all resources with World.resources() #1891

alice-i-cecile opened this issue Apr 12, 2021 · 7 comments
Labels
A-ECS Entities, components, systems, and events C-Enhancement A new feature

Comments

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Apr 12, 2021

What problem does this solve or what need does it fill?

It would be useful to be able to see which Resources exist in the world, for debugging, discovery and editor purposes.

What solution would you like?

Expose a .resources() method on World.

What alternative(s) have you considered?

This may exist and I missed it. In that case, organization or documentation needs work instead.

Additional context

This appears to have been lost in #1525; this functionality exists in 0.4, but not in 0.5. Edit: I was mistaken about behavior in 0.4; this is new functionality.

Resources are now a part of World, but it doesn't seem to be accessible from that.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events D-Trivial Nice and easy! A great choice to get started with Bevy C-Regression Functionality that used to work but no longer does. Add a test for this! labels Apr 12, 2021
@mockersf
Copy link
Member

mockersf commented Apr 12, 2021

there is get_resource https://docs.rs/bevy/0.5.0/bevy/ecs/world/struct.World.html#method.get_resource for inspiration on how to list resources

@Sheepyhead
Copy link
Contributor

It's not really obvious what this .resources() method should actually return, as a resource can be any type. Clarification is needed on what the returned values of this function needs to be used for, and what data should be returned

@concave-sphere
Copy link

It might be worth having a set of debug specific APIs that return types that are easy to dump to stdout or logs. e.g, get_all_resource_names(&self) -> String. I've also had cause to implement my own code to get a String showing which components are attached to an Entity.

@Frizi
Copy link
Contributor

Frizi commented Apr 12, 2021

I don't think there is any actual regression. There never was a way to access a list of resources. As far as I can tell not even a Debug impl. All methods on the Resources struct were generic over a resource type, thus serving the same purpose as existing World. So, maybe we want something like that, but I would argue it should be designed as targeted for specific use case (probably editor).

@alice-i-cecile alice-i-cecile added C-Enhancement A new feature and removed D-Trivial Nice and easy! A great choice to get started with Bevy C-Regression Functionality that used to work but no longer does. Add a test for this! labels Apr 12, 2021
@alice-i-cecile alice-i-cecile changed the title Re-implement World.resources() View all resources with World.resources() Apr 12, 2021
@alice-i-cecile
Copy link
Member Author

Closely related to #1130.

@alice-i-cecile
Copy link
Member Author

alice-i-cecile commented Apr 18, 2021

There's some nice external-APIs only example code that does approximately this over on bevy-cheatbook/bevy-cheatbook#61 :)

@alice-i-cecile
Copy link
Member Author

Duplicate of #3007, which has more progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Enhancement A new feature
Projects
None yet
Development

No branches or pull requests

5 participants