Trait bevy_asset::AddAsset
source · pub trait AddAsset {
// Required methods
fn add_asset<T>(&mut self) -> &mut Self
where T: Asset;
fn register_asset_reflect<T>(&mut self) -> &mut Self
where T: Asset + Reflect + FromReflect + GetTypeRegistration;
fn add_debug_asset<T>(&mut self) -> &mut Self
where T: Asset + Clone;
fn init_asset_loader<T>(&mut self) -> &mut Self
where T: AssetLoader + FromWorld;
fn init_debug_asset_loader<T>(&mut self) -> &mut Self
where T: AssetLoader + FromWorld;
fn add_asset_loader<T>(&mut self, loader: T) -> &mut Self
where T: AssetLoader;
fn preregister_asset_loader(&mut self, extensions: &[&str]) -> &mut Self;
}
Expand description
App
extension methods for adding new asset types.
Required Methods§
sourcefn add_asset<T>(&mut self) -> &mut Selfwhere
T: Asset,
fn add_asset<T>(&mut self) -> &mut Selfwhere T: Asset,
Registers T
as a supported asset in the application.
Adding the same type again after it has been added does nothing.
sourcefn register_asset_reflect<T>(&mut self) -> &mut Selfwhere
T: Asset + Reflect + FromReflect + GetTypeRegistration,
fn register_asset_reflect<T>(&mut self) -> &mut Selfwhere T: Asset + Reflect + FromReflect + GetTypeRegistration,
Registers the asset type T
using App::register_type
,
and adds ReflectAsset
type data to T
and ReflectHandle
type data to Handle<T>
in the type registry.
This enables reflection code to access assets. For detailed information, see the docs on ReflectAsset
and ReflectHandle
.
sourcefn add_debug_asset<T>(&mut self) -> &mut Selfwhere
T: Asset + Clone,
fn add_debug_asset<T>(&mut self) -> &mut Selfwhere T: Asset + Clone,
Registers T
as a supported internal asset in the application.
Internal assets (e.g. shaders) are bundled directly into the app and can’t be hot reloaded
using the conventional API. See DebugAssetServerPlugin
.
Adding the same type again after it has been added does nothing.
sourcefn init_asset_loader<T>(&mut self) -> &mut Selfwhere
T: AssetLoader + FromWorld,
fn init_asset_loader<T>(&mut self) -> &mut Selfwhere T: AssetLoader + FromWorld,
Adds an asset loader T
using default values.
The default values may come from the World
or from T::default()
.
sourcefn init_debug_asset_loader<T>(&mut self) -> &mut Selfwhere
T: AssetLoader + FromWorld,
fn init_debug_asset_loader<T>(&mut self) -> &mut Selfwhere T: AssetLoader + FromWorld,
Adds an asset loader T
for internal assets using default values.
Internal assets (e.g. shaders) are bundled directly into the app and can’t be hot reloaded
using the conventional API. See DebugAssetServerPlugin
.
The default values may come from the World
or from T::default()
.
sourcefn add_asset_loader<T>(&mut self, loader: T) -> &mut Selfwhere
T: AssetLoader,
fn add_asset_loader<T>(&mut self, loader: T) -> &mut Selfwhere T: AssetLoader,
Adds the provided asset loader to the application.
sourcefn preregister_asset_loader(&mut self, extensions: &[&str]) -> &mut Self
fn preregister_asset_loader(&mut self, extensions: &[&str]) -> &mut Self
Preregisters a loader for the given extensions, that will block asset loads until a real loader is registered.