pub enum Handle<A>where
A: Asset,{
Strong(Arc<StrongHandle>),
Weak(AssetId<A>),
}
Expand description
A strong or weak handle to a specific Asset
. If a Handle
is Handle::Strong
, the Asset
will be kept
alive until the Handle
is dropped. If a Handle
is Handle::Weak
, it does not necessarily reference a live Asset
,
nor will it keep assets alive.
Handle
can be cloned. If a Handle::Strong
is cloned, the referenced Asset
will not be freed until all instances
of the Handle
are dropped.
Handle::Strong
also provides access to useful Asset
metadata, such as the AssetPath
(if it exists).
Variants§
Strong(Arc<StrongHandle>)
A “strong” reference to a live (or loading) Asset
. If a Handle
is Handle::Strong
, the Asset
will be kept
alive until the Handle
is dropped. Strong handles also provide access to additional asset metadata.
Weak(AssetId<A>)
A “weak” reference to an Asset
. If a Handle
is Handle::Weak
, it does not necessarily reference a live Asset
,
nor will it keep assets alive.
Implementations§
source§impl<A> Handle<A>where
A: Asset,
impl<A> Handle<A>where
A: Asset,
sourcepub const fn weak_from_u128(value: u128) -> Handle<A>
pub const fn weak_from_u128(value: u128) -> Handle<A>
Create a new Handle::Weak
with the given u128
encoding of a Uuid
.
sourcepub fn id(&self) -> AssetId<A>
pub fn id(&self) -> AssetId<A>
Examples found in repository?
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
fn resize_image(
image_mesh: Query<(&Handle<StandardMaterial>, &Handle<Mesh>), With<HDRViewer>>,
materials: Res<Assets<StandardMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
images: Res<Assets<Image>>,
mut image_events: EventReader<AssetEvent<Image>>,
) {
for event in image_events.read() {
let (AssetEvent::Added { id } | AssetEvent::Modified { id }) = event else {
continue;
};
for (mat_h, mesh_h) in &image_mesh {
let Some(mat) = materials.get(mat_h) else {
continue;
};
let Some(ref base_color_texture) = mat.base_color_texture else {
continue;
};
if *id != base_color_texture.id() {
continue;
};
let Some(image_changed) = images.get(*id) else {
continue;
};
let size = image_changed.size_f32().normalize_or_zero() * 1.4;
// Resize Mesh
let quad = Mesh::from(Rectangle::from_size(size));
meshes.insert(mesh_h, quad);
}
}
}
More examples
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
fn create_array_texture(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut loading_texture: ResMut<LoadingTexture>,
mut images: ResMut<Assets<Image>>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ArrayTextureMaterial>>,
) {
if loading_texture.is_loaded
|| asset_server.load_state(loading_texture.handle.id()) != LoadState::Loaded
{
return;
}
loading_texture.is_loaded = true;
let image = images.get_mut(&loading_texture.handle).unwrap();
// Create a new array texture asset from the loaded texture.
let array_layers = 4;
image.reinterpret_stacked_2d_as_array(array_layers);
// Spawn some cubes using the array texture
let mesh_handle = meshes.add(Cuboid::default());
let material_handle = materials.add(ArrayTextureMaterial {
array_texture: loading_texture.handle.clone(),
});
for x in -5..=5 {
commands.spawn(MaterialMeshBundle {
mesh: mesh_handle.clone(),
material: material_handle.clone(),
transform: Transform::from_xyz(x as f32 + 0.5, 0.0, 0.0),
..Default::default()
});
}
}
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
pub fn extract_colored_mesh2d(
mut commands: Commands,
mut previous_len: Local<usize>,
// When extracting, you must use `Extract` to mark the `SystemParam`s
// which should be taken from the main world.
query: Extract<
Query<(Entity, &ViewVisibility, &GlobalTransform, &Mesh2dHandle), With<ColoredMesh2d>>,
>,
mut render_mesh_instances: ResMut<RenderColoredMesh2dInstances>,
) {
let mut values = Vec::with_capacity(*previous_len);
for (entity, view_visibility, transform, handle) in &query {
if !view_visibility.get() {
continue;
}
let transforms = Mesh2dTransforms {
world_from_local: (&transform.affine()).into(),
flags: MeshFlags::empty().bits(),
};
values.push((entity, ColoredMesh2d));
render_mesh_instances.insert(
entity,
RenderMesh2dInstance {
mesh_asset_id: handle.0.id(),
transforms,
material_bind_group_id: Material2dBindGroupId::default(),
automatic_batching: false,
},
);
}
*previous_len = values.len();
commands.insert_or_spawn_batch(values);
}
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
fn update(
images_to_save: Query<&ImageToSave>,
receiver: Res<MainWorldReceiver>,
mut images: ResMut<Assets<Image>>,
mut scene_controller: ResMut<SceneController>,
mut app_exit_writer: EventWriter<AppExit>,
mut file_number: Local<u32>,
) {
if let SceneState::Render(n) = scene_controller.state {
if n < 1 {
// We don't want to block the main world on this,
// so we use try_recv which attempts to receive without blocking
let mut image_data = Vec::new();
while let Ok(data) = receiver.try_recv() {
// image generation could be faster than saving to fs,
// that's why use only last of them
image_data = data;
}
if !image_data.is_empty() {
for image in images_to_save.iter() {
// Fill correct data from channel to image
let img_bytes = images.get_mut(image.id()).unwrap();
// We need to ensure that this works regardless of the image dimensions
// If the image became wider when copying from the texture to the buffer,
// then the data is reduced to its original size when copying from the buffer to the image.
let row_bytes = img_bytes.width() as usize
* img_bytes.texture_descriptor.format.pixel_size();
let aligned_row_bytes = RenderDevice::align_copy_bytes_per_row(row_bytes);
if row_bytes == aligned_row_bytes {
img_bytes.data.clone_from(&image_data);
} else {
// shrink data to original image size
img_bytes.data = image_data
.chunks(aligned_row_bytes)
.take(img_bytes.height() as usize)
.flat_map(|row| &row[..row_bytes.min(row.len())])
.cloned()
.collect();
}
// Create RGBA Image Buffer
let img = match img_bytes.clone().try_into_dynamic() {
Ok(img) => img.to_rgba8(),
Err(e) => panic!("Failed to create image buffer {e:?}"),
};
// Prepare directory for images, test_images in bevy folder is used here for example
// You should choose the path depending on your needs
let images_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test_images");
info!("Saving image to: {images_dir:?}");
std::fs::create_dir_all(&images_dir).unwrap();
// Choose filename starting from 000.png
let image_path = images_dir.join(format!("{:03}.png", file_number.deref()));
*file_number.deref_mut() += 1;
// Finally saving image to file, this heavy blocking operation is kept here
// for example simplicity, but in real app you should move it to a separate task
if let Err(e) = img.save(image_path) {
panic!("Failed to save image: {}", e);
};
}
if scene_controller.single_image {
app_exit_writer.send(AppExit::Success);
}
}
} else {
// clears channel for skipped frames
while receiver.try_recv().is_ok() {}
scene_controller.state = SceneState::Render(n - 1);
}
}
}
sourcepub fn path(&self) -> Option<&AssetPath<'static>>
pub fn path(&self) -> Option<&AssetPath<'static>>
Returns the path if this is (1) a strong handle and (2) the asset has a path
sourcepub fn clone_weak(&self) -> Handle<A>
pub fn clone_weak(&self) -> Handle<A>
Creates a Handle::Weak
clone of this Handle
, which will not keep the referenced Asset
alive.
Examples found in repository?
More examples
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
let font = asset_server.load("fonts/FiraMono-Medium.ttf");
commands.spawn(
TextBundle::from_sections([
TextSection {
value: "IME Enabled: ".to_string(),
style: TextStyle {
font: font.clone_weak(),
..default()
},
},
TextSection {
value: "false\n".to_string(),
style: TextStyle {
font: font.clone_weak(),
font_size: 30.0,
..default()
},
},
TextSection {
value: "IME Active: ".to_string(),
style: TextStyle {
font: font.clone_weak(),
..default()
},
},
TextSection {
value: "false\n".to_string(),
style: TextStyle {
font: font.clone_weak(),
font_size: 30.0,
..default()
},
},
TextSection {
value: "click to toggle IME, press return to start a new line\n\n".to_string(),
style: TextStyle {
font: font.clone_weak(),
font_size: 18.0,
..default()
},
},
TextSection {
value: "".to_string(),
style: TextStyle {
font,
font_size: 25.0,
..default()
},
},
])
.with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(10.0),
left: Val::Px(10.0),
..default()
}),
);
commands.spawn(Text2dBundle {
text: Text::from_section(
"".to_string(),
TextStyle {
font: asset_server.load("fonts/FiraMono-Medium.ttf"),
font_size: 100.0,
..default()
},
),
..default()
});
}
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
fn setup(
mut commands: Commands,
mut materials: ResMut<Assets<StandardMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
asset_server: Res<AssetServer>,
) {
// The normal map. Note that to generate it in the GIMP image editor, you should
// open the depth map, and do Filters → Generic → Normal Map
// You should enable the "flip X" checkbox.
let normal_handle = asset_server.load_with_settings(
"textures/parallax_example/cube_normal.png",
// The normal map texture is in linear color space. Lighting won't look correct
// if `is_srgb` is `true`, which is the default.
|settings: &mut ImageLoaderSettings| settings.is_srgb = false,
);
// Camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::ZERO, Vec3::Y),
..default()
},
CameraController,
));
// light
commands
.spawn(PointLightBundle {
transform: Transform::from_xyz(2.0, 1.0, -1.1),
point_light: PointLight {
shadows_enabled: true,
..default()
},
..default()
})
.with_children(|commands| {
// represent the light source as a sphere
let mesh = meshes.add(Sphere::new(0.05).mesh().ico(3).unwrap());
commands.spawn(PbrBundle { mesh, ..default() });
});
// Plane
commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(10.0, 10.0)),
material: materials.add(StandardMaterial {
// standard material derived from dark green, but
// with roughness and reflectance set.
perceptual_roughness: 0.45,
reflectance: 0.18,
..Color::srgb_u8(0, 80, 0).into()
}),
transform: Transform::from_xyz(0.0, -1.0, 0.0),
..default()
});
let parallax_depth_scale = TargetDepth::default().0;
let max_parallax_layer_count = TargetLayers::default().0.exp2();
let parallax_mapping_method = CurrentMethod::default();
let parallax_material = materials.add(StandardMaterial {
perceptual_roughness: 0.4,
base_color_texture: Some(asset_server.load("textures/parallax_example/cube_color.png")),
normal_map_texture: Some(normal_handle),
// The depth map is a greyscale texture where black is the highest level and
// white the lowest.
depth_map: Some(asset_server.load("textures/parallax_example/cube_depth.png")),
parallax_depth_scale,
parallax_mapping_method: parallax_mapping_method.0,
max_parallax_layer_count,
..default()
});
commands.spawn((
PbrBundle {
mesh: meshes.add(
// NOTE: for normal maps and depth maps to work, the mesh
// needs tangents generated.
Mesh::from(Cuboid::default())
.with_generated_tangents()
.unwrap(),
),
material: parallax_material.clone_weak(),
..default()
},
Spin { speed: 0.3 },
));
let background_cube = meshes.add(
Mesh::from(Cuboid::new(40.0, 40.0, 40.0))
.with_generated_tangents()
.unwrap(),
);
let background_cube_bundle = |translation| {
(
PbrBundle {
transform: Transform::from_translation(translation),
mesh: background_cube.clone(),
material: parallax_material.clone(),
..default()
},
Spin { speed: -0.1 },
)
};
commands.spawn(background_cube_bundle(Vec3::new(45., 0., 0.)));
commands.spawn(background_cube_bundle(Vec3::new(-45., 0., 0.)));
commands.spawn(background_cube_bundle(Vec3::new(0., 0., 45.)));
commands.spawn(background_cube_bundle(Vec3::new(0., 0., -45.)));
let style = TextStyle::default();
// example instructions
commands.spawn(
TextBundle::from_sections(vec![
TextSection::new(
format!("Parallax depth scale: {parallax_depth_scale:.5}\n"),
style.clone(),
),
TextSection::new(
format!("Layers: {max_parallax_layer_count:.0}\n"),
style.clone(),
),
TextSection::new(format!("{parallax_mapping_method}\n"), style.clone()),
TextSection::new("\n\n", style.clone()),
TextSection::new("Controls:\n", style.clone()),
TextSection::new("Left click - Change view angle\n", style.clone()),
TextSection::new(
"1/2 - Decrease/Increase parallax depth scale\n",
style.clone(),
),
TextSection::new("3/4 - Decrease/Increase layer count\n", style.clone()),
TextSection::new("Space - Switch parallaxing algorithm\n", style),
])
.with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0),
left: Val::Px(12.0),
..default()
}),
);
}
sourcepub fn untyped(self) -> UntypedHandle
pub fn untyped(self) -> UntypedHandle
Converts this Handle
to an “untyped” / “generic-less” UntypedHandle
, which stores the Asset
type information
inside UntypedHandle
. This will return UntypedHandle::Strong
for Handle::Strong
and UntypedHandle::Weak
for
Handle::Weak
.
Trait Implementations§
source§impl<A> Component for Handle<A>
impl<A> Component for Handle<A>
source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
source§fn register_component_hooks(_hooks: &mut ComponentHooks)
fn register_component_hooks(_hooks: &mut ComponentHooks)
ComponentHooks
.source§impl<A> Enum for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
impl<A> Enum for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
source§fn field(&self, __name_param: &str) -> Option<&(dyn Reflect + 'static)>
fn field(&self, __name_param: &str) -> Option<&(dyn Reflect + 'static)>
source§fn field_at(&self, __index_param: usize) -> Option<&(dyn Reflect + 'static)>
fn field_at(&self, __index_param: usize) -> Option<&(dyn Reflect + 'static)>
source§fn field_mut(
&mut self,
__name_param: &str,
) -> Option<&mut (dyn Reflect + 'static)>
fn field_mut( &mut self, __name_param: &str, ) -> Option<&mut (dyn Reflect + 'static)>
source§fn field_at_mut(
&mut self,
__index_param: usize,
) -> Option<&mut (dyn Reflect + 'static)>
fn field_at_mut( &mut self, __index_param: usize, ) -> Option<&mut (dyn Reflect + 'static)>
source§fn index_of(&self, __name_param: &str) -> Option<usize>
fn index_of(&self, __name_param: &str) -> Option<usize>
source§fn name_at(&self, __index_param: usize) -> Option<&str>
fn name_at(&self, __index_param: usize) -> Option<&str>
source§fn iter_fields(&self) -> VariantFieldIter<'_> ⓘ
fn iter_fields(&self) -> VariantFieldIter<'_> ⓘ
source§fn variant_name(&self) -> &str
fn variant_name(&self) -> &str
source§fn variant_index(&self) -> usize
fn variant_index(&self) -> usize
source§fn variant_type(&self) -> VariantType
fn variant_type(&self) -> VariantType
fn clone_dynamic(&self) -> DynamicEnum
source§fn is_variant(&self, variant_type: VariantType) -> bool
fn is_variant(&self, variant_type: VariantType) -> bool
source§fn variant_path(&self) -> String
fn variant_path(&self) -> String
source§impl<T> ExtractComponent for Handle<T>where
T: Asset,
impl<T> ExtractComponent for Handle<T>where
T: Asset,
source§type QueryData = &'static Handle<T>
type QueryData = &'static Handle<T>
ReadOnlyQueryData
to fetch the components to extract.source§type QueryFilter = ()
type QueryFilter = ()
source§fn extract_component(
handle: <<Handle<T> as ExtractComponent>::QueryData as WorldQuery>::Item<'_>,
) -> Option<<Handle<T> as ExtractComponent>::Out>
fn extract_component( handle: <<Handle<T> as ExtractComponent>::QueryData as WorldQuery>::Item<'_>, ) -> Option<<Handle<T> as ExtractComponent>::Out>
source§impl<A> From<&Handle<A>> for UntypedAssetIdwhere
A: Asset,
impl<A> From<&Handle<A>> for UntypedAssetIdwhere
A: Asset,
source§fn from(value: &Handle<A>) -> UntypedAssetId
fn from(value: &Handle<A>) -> UntypedAssetId
source§impl<A> From<&mut Handle<A>> for UntypedAssetIdwhere
A: Asset,
impl<A> From<&mut Handle<A>> for UntypedAssetIdwhere
A: Asset,
source§fn from(value: &mut Handle<A>) -> UntypedAssetId
fn from(value: &mut Handle<A>) -> UntypedAssetId
source§impl<A> From<Handle<A>> for UntypedHandlewhere
A: Asset,
impl<A> From<Handle<A>> for UntypedHandlewhere
A: Asset,
source§fn from(value: Handle<A>) -> UntypedHandle
fn from(value: Handle<A>) -> UntypedHandle
source§impl From<Handle<TextureAtlasLayout>> for TextureAtlas
impl From<Handle<TextureAtlasLayout>> for TextureAtlas
source§fn from(texture_atlas: Handle<TextureAtlasLayout>) -> TextureAtlas
fn from(texture_atlas: Handle<TextureAtlasLayout>) -> TextureAtlas
source§impl<A> FromReflect for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
impl<A> FromReflect for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
source§fn from_reflect(__param0: &(dyn Reflect + 'static)) -> Option<Handle<A>>
fn from_reflect(__param0: &(dyn Reflect + 'static)) -> Option<Handle<A>>
Self
from a reflected value.source§fn take_from_reflect(
reflect: Box<dyn Reflect>,
) -> Result<Self, Box<dyn Reflect>>
fn take_from_reflect( reflect: Box<dyn Reflect>, ) -> Result<Self, Box<dyn Reflect>>
Self
using,
constructing the value using from_reflect
if that fails. Read moresource§impl<A> FromType<Handle<A>> for ReflectHandlewhere
A: Asset,
impl<A> FromType<Handle<A>> for ReflectHandlewhere
A: Asset,
fn from_type() -> ReflectHandle
source§impl<A> GetTypeRegistration for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
impl<A> GetTypeRegistration for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
source§fn get_type_registration() -> TypeRegistration
fn get_type_registration() -> TypeRegistration
TypeRegistration
for this type.source§fn register_type_dependencies(registry: &mut TypeRegistry)
fn register_type_dependencies(registry: &mut TypeRegistry)
source§impl<A> Ord for Handle<A>where
A: Asset,
impl<A> Ord for Handle<A>where
A: Asset,
source§impl<A> PartialOrd<Handle<A>> for UntypedHandlewhere
A: Asset,
impl<A> PartialOrd<Handle<A>> for UntypedHandlewhere
A: Asset,
source§impl<A> PartialOrd<UntypedHandle> for Handle<A>where
A: Asset,
impl<A> PartialOrd<UntypedHandle> for Handle<A>where
A: Asset,
source§impl<A> PartialOrd for Handle<A>where
A: Asset,
impl<A> PartialOrd for Handle<A>where
A: Asset,
source§impl<A> Reflect for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
impl<A> Reflect for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut dyn Any
.source§fn into_reflect(self: Box<Handle<A>>) -> Box<dyn Reflect>
fn into_reflect(self: Box<Handle<A>>) -> Box<dyn Reflect>
source§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
source§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
source§fn clone_value(&self) -> Box<dyn Reflect>
fn clone_value(&self) -> Box<dyn Reflect>
Reflect
trait object. Read moresource§fn set(
&mut self,
__value_param: Box<dyn Reflect>,
) -> Result<(), Box<dyn Reflect>>
fn set( &mut self, __value_param: Box<dyn Reflect>, ) -> Result<(), Box<dyn Reflect>>
source§fn try_apply(
&mut self,
__value_param: &(dyn Reflect + 'static),
) -> Result<(), ApplyError>
fn try_apply( &mut self, __value_param: &(dyn Reflect + 'static), ) -> Result<(), ApplyError>
source§fn reflect_kind(&self) -> ReflectKind
fn reflect_kind(&self) -> ReflectKind
source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
source§fn reflect_owned(self: Box<Handle<A>>) -> ReflectOwned
fn reflect_owned(self: Box<Handle<A>>) -> ReflectOwned
source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
source§fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
source§fn apply(&mut self, value: &(dyn Reflect + 'static))
fn apply(&mut self, value: &(dyn Reflect + 'static))
source§fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
source§impl<A> TryFrom<UntypedHandle> for Handle<A>where
A: Asset,
impl<A> TryFrom<UntypedHandle> for Handle<A>where
A: Asset,
source§type Error = UntypedAssetConversionError
type Error = UntypedAssetConversionError
source§fn try_from(
value: UntypedHandle,
) -> Result<Handle<A>, <Handle<A> as TryFrom<UntypedHandle>>::Error>
fn try_from( value: UntypedHandle, ) -> Result<Handle<A>, <Handle<A> as TryFrom<UntypedHandle>>::Error>
source§impl<A> TypePath for Handle<A>
impl<A> TypePath for Handle<A>
source§fn type_path() -> &'static str
fn type_path() -> &'static str
source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
source§impl<A> Typed for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
impl<A> Typed for Handle<A>where
A: Asset + TypePath,
Handle<A>: Any + Send + Sync,
Arc<StrongHandle>: FromReflect + TypePath + RegisterForReflection,
AssetId<A>: FromReflect + TypePath + RegisterForReflection,
source§impl<A> VisitAssetDependencies for Handle<A>where
A: Asset,
impl<A> VisitAssetDependencies for Handle<A>where
A: Asset,
fn visit_dependencies(&self, visit: &mut impl FnMut(UntypedAssetId))
impl<A> Eq for Handle<A>where
A: Asset,
Auto Trait Implementations§
impl<A> Freeze for Handle<A>
impl<A> !RefUnwindSafe for Handle<A>
impl<A> Send for Handle<A>
impl<A> Sync for Handle<A>
impl<A> Unpin for Handle<A>
impl<A> !UnwindSafe for Handle<A>
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId), )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
source§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))
source§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
source§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
TypePath::type_path
.source§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
source§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
TypePath::type_ident
.source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
TypePath::crate_name
.source§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.source§impl<T> GetPath for T
impl<T> GetPath for T
source§fn reflect_path<'p>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&(dyn Reflect + 'static), ReflectPathError<'p>>
fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read moresource§fn reflect_path_mut<'p>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read moresource§fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
path
. Read moresource§fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
path
. Read moresource§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.