Open huhlig opened 3 years ago
The way it's down to get the same handle from a path is that the handle is derived from the path directly.
If we add handle-derived-from-name, what happens if I use the same name for different assets? New one rejected, or old ones now point to new asset?
Should a named asset be cleaned if there are no current strong handle to it, even though the user could still recreate an handle?
Currently we already have handles by name, the name is just fixed from the path when it's loaded, and technically if we have multiple asset packs we would have the same issue.
Path are specials in that they represent a link to the original file, so:
Also, for the method on asset server: AssetServer::get_handle_by_name(name: &str) -> Handle<T>;
: if the user never adds the name through the Assets::add_as
methods, it will returns an handle that will never resolve.
You're right, it should return Option::None
What problem does this solve or what need does it fill?
Currently only assets loaded by AssetServer::load have names and it's fixed as the name of the path. Looking up a loaded assets is as simple as calling load a second time. However assets that are created don't have this luxury thus requiring custom cataloging of handles to provide lookup.
What solution would you like?
Add new methods
What alternative(s) have you considered?
Adding custom catalog for assets. This while doable seems like an anti-pattern as all handles will need to be cloned into the catalog.