bevy_asset

Trait AssetApp

Source
pub trait AssetApp {
    // Required methods
    fn register_asset_loader<L: AssetLoader>(&mut self, loader: L) -> &mut Self;
    fn register_asset_processor<P: Process>(
        &mut self,
        processor: P,
    ) -> &mut Self;
    fn register_asset_source(
        &mut self,
        id: impl Into<AssetSourceId<'static>>,
        source: AssetSourceBuilder,
    ) -> &mut Self;
    fn set_default_asset_processor<P: Process>(
        &mut self,
        extension: &str,
    ) -> &mut Self;
    fn init_asset_loader<L: AssetLoader + FromWorld>(&mut self) -> &mut Self;
    fn init_asset<A: Asset>(&mut self) -> &mut Self;
    fn register_asset_reflect<A>(&mut self) -> &mut Self
       where A: Asset + Reflect + FromReflect + GetTypeRegistration;
    fn preregister_asset_loader<L: AssetLoader>(
        &mut self,
        extensions: &[&str],
    ) -> &mut Self;
}
Expand description

Adds asset-related builder methods to App.

Required Methods§

Source

fn register_asset_loader<L: AssetLoader>(&mut self, loader: L) -> &mut Self

Registers the given loader in the App’s AssetServer.

Source

fn register_asset_processor<P: Process>(&mut self, processor: P) -> &mut Self

Registers the given processor in the App’s AssetProcessor.

Source

fn register_asset_source( &mut self, id: impl Into<AssetSourceId<'static>>, source: AssetSourceBuilder, ) -> &mut Self

Registers the given AssetSourceBuilder with the given id.

Note that asset sources must be registered before adding AssetPlugin to your application, since registered asset sources are built at that point and not after.

Source

fn set_default_asset_processor<P: Process>( &mut self, extension: &str, ) -> &mut Self

Sets the default asset processor for the given extension.

Source

fn init_asset_loader<L: AssetLoader + FromWorld>(&mut self) -> &mut Self

Initializes the given loader in the App’s AssetServer.

Source

fn init_asset<A: Asset>(&mut self) -> &mut Self

Initializes the given Asset in the App by:

  • Registering the Asset in the AssetServer
  • Initializing the AssetEvent resource for the Asset
  • Adding other relevant systems and resources for the Asset
  • Ignoring schedule ambiguities in Assets resource. Any time a system takes mutable access to this resource this causes a conflict, but they rarely actually modify the same underlying asset.
Source

fn register_asset_reflect<A>(&mut self) -> &mut Self

Registers the asset type T using [App::register], 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.

Source

fn preregister_asset_loader<L: AssetLoader>( &mut self, extensions: &[&str], ) -> &mut Self

Preregisters a loader for the given extensions, that will block asset loads until a real loader is registered.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AssetApp for App

Source§

fn register_asset_loader<L: AssetLoader>(&mut self, loader: L) -> &mut Self

Source§

fn register_asset_processor<P: Process>(&mut self, processor: P) -> &mut Self

Source§

fn register_asset_source( &mut self, id: impl Into<AssetSourceId<'static>>, source: AssetSourceBuilder, ) -> &mut Self

Source§

fn set_default_asset_processor<P: Process>( &mut self, extension: &str, ) -> &mut Self

Source§

fn init_asset_loader<L: AssetLoader + FromWorld>(&mut self) -> &mut Self

Source§

fn init_asset<A: Asset>(&mut self) -> &mut Self

Source§

fn register_asset_reflect<A>(&mut self) -> &mut Self

Source§

fn preregister_asset_loader<L: AssetLoader>( &mut self, extensions: &[&str], ) -> &mut Self

Implementors§