Struct amethyst_assets::Loader
source · pub struct Loader { /* private fields */ }
Expand description
The asset loader, holding the sources and a reference to the ThreadPool
.
Implementations
sourceimpl Loader
impl Loader
sourcepub fn new<P>(directory: P, pool: Arc<ThreadPool>) -> Selfwhere
P: Into<PathBuf>,
pub fn new<P>(directory: P, pool: Arc<ThreadPool>) -> Selfwhere
P: Into<PathBuf>,
Creates a new asset loader, initializing the directory store with the given path.
sourcepub fn add_source<I, S>(&mut self, id: I, source: S)where
I: Into<String>,
S: Source,
pub fn add_source<I, S>(&mut self, id: I, source: S)where
I: Into<String>,
S: Source,
Add a source to the Loader
, given an id and the source.
sourcepub fn set_hot_reload(&mut self, value: bool)
pub fn set_hot_reload(&mut self, value: bool)
If set to true
, this Loader
will ask formats to
generate “reload instructions” which allow reloading.
Calling set_hot_reload(true)
does not actually enable
hot reloading; this is controlled by the HotReloadStrategy
resource.
sourcepub fn load<A, F, N, P>(
&self,
name: N,
format: F,
options: F::Options,
progress: P,
storage: &AssetStorage<A>
) -> Handle<A>where
A: Asset,
F: Format<A>,
N: Into<String>,
P: Progress,
pub fn load<A, F, N, P>(
&self,
name: N,
format: F,
options: F::Options,
progress: P,
storage: &AssetStorage<A>
) -> Handle<A>where
A: Asset,
F: Format<A>,
N: Into<String>,
P: Progress,
Loads an asset with a given format from the default (directory) source.
If you want to load from a custom source instead, use load_from
.
See load_from
for more information.
sourcepub fn load_from<A, F, N, P, S>(
&self,
name: N,
format: F,
options: F::Options,
source: &S,
progress: P,
storage: &AssetStorage<A>
) -> Handle<A>where
A: Asset,
F: Format<A> + 'static,
N: Into<String>,
P: Progress,
S: AsRef<str> + Eq + Hash + ?Sized,
String: Borrow<S>,
pub fn load_from<A, F, N, P, S>(
&self,
name: N,
format: F,
options: F::Options,
source: &S,
progress: P,
storage: &AssetStorage<A>
) -> Handle<A>where
A: Asset,
F: Format<A> + 'static,
N: Into<String>,
P: Progress,
S: AsRef<str> + Eq + Hash + ?Sized,
String: Borrow<S>,
Loads an asset with a given id and format from a custom source. The actual work is done in a worker thread, thus this method immediately returns a handle.
Parameters
name
: this is just an identifier for the asset, most likely a file name e.g."meshes/a.obj"
format
: A format struct which loads bytes from asource
and producesAsset::Data
with themoptions
: Additional parameter toformat
to configure how exactly the data will be created. This could e.g. be mipmap levels for textures.source
: An identifier for a source which has previously been added usingwith_source
progress
: A tracker which will be notified of assets which have been importedstorage
: The asset storage which can be fetched from the ECSWorld
usingread_resource
.
sourcepub fn load_from_data<A, P>(
&self,
data: A::Data,
progress: P,
storage: &AssetStorage<A>
) -> Handle<A>where
A: Asset,
P: Progress,
pub fn load_from_data<A, P>(
&self,
data: A::Data,
progress: P,
storage: &AssetStorage<A>
) -> Handle<A>where
A: Asset,
P: Progress,
Load an asset from data and return a handle.
Auto Trait Implementations
impl !RefUnwindSafe for Loader
impl Send for Loader
impl Sync for Loader
impl Unpin for Loader
impl !UnwindSafe for Loader
Blanket Implementations
impl<T> Any for Twhere
T: Any,
impl<T> Any for Twhere
T: Any,
fn get_type_id(&self) -> TypeId
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Pointable for T
impl<T> Pointable for T
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.