-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Ability to get dimensions of image file #10982
Comments
Just to clarify, Is this specifically for use inside an |
And while I expect there is a path for turning a It could well be that I'm missing something, but as things are it feels less than ideal. |
Yeah the problem is that assets are loaded asynchronously. And as far as I know, there is no way to await their loading in the same system. What you probably want to do is use states instead of a startup system. This way you can remain in the You can check the load state with All that to say, there is a way of getting the image size, but it requires a bit of change to the way your systems are organized. I think for Bevy to make this easier, we either need to add a method to |
Yeah see that's a bit frustrating considering just how much architectural overhead it would introduce just to load my game's one (1) image file. It would be nice to have some way to 1) block on loading assets, for small one-time loads like this and 2) get the actual asset directly from the asset server or something. |
Yeah especially for small assets, a synchronous approach could be nice. See also #1701. |
What problem does this solve or what need does it fill?
When loading an image asset from a file, there doesn’t seem to be any way to easily get the dimensions of the image. This makes it really annoying to do things dependent on image size (like dwarf-fortress style tile sets where you have a fixed layout and number of tiles but the actual size of those tiles is dependent on the actual texture size).
What solution would you like?
A way to easily get the dimensions of an image file in the assets directory, preferably while loading the asset so this can be done in startup systems.
What alternative(s) have you considered?
I could use a separate mechanism to access the image file outside of bevy’s asset-handling machinery, but that would probably add extra dependencies and really complicate things.
Additional context
In many game engines, such as macroquad or dragonruby, this is a natively supported feature. It is quite essential for doing any kind of one-time calculations that depend on the size of a texture, and its omission in bevy seems like an oversight.
The text was updated successfully, but these errors were encountered: