mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
f18f28874a
# Objective - Better consistency with `add_systems`. - Deprecating `add_plugin` in favor of a more powerful `add_plugins`. - Allow passing `Plugin` to `add_plugins`. - Allow passing tuples to `add_plugins`. ## Solution - `App::add_plugins` now takes an `impl Plugins` parameter. - `App::add_plugin` is deprecated. - `Plugins` is a new sealed trait that is only implemented for `Plugin`, `PluginGroup` and tuples over `Plugins`. - All examples, benchmarks and tests are changed to use `add_plugins`, using tuples where appropriate. --- ## Changelog ### Changed - `App::add_plugins` now accepts all types that implement `Plugins`, which is implemented for: - Types that implement `Plugin`. - Types that implement `PluginGroup`. - Tuples (up to 16 elements) over types that implement `Plugins`. - Deprecated `App::add_plugin` in favor of `App::add_plugins`. ## Migration Guide - Replace `app.add_plugin(plugin)` calls with `app.add_plugins(plugin)`. --------- Co-authored-by: Carter Anderson <mcanders1@gmail.com>
79 lines
2.2 KiB
Rust
79 lines
2.2 KiB
Rust
//! This example tests that all texture dimensions are supported by
|
|
//! `FallbackImage`.
|
|
//!
|
|
//! When running this example, you should expect to see a window that only draws
|
|
//! the clear color. The test material does not shade any geometry; this example
|
|
//! only tests that the images are initialized and bound so that the app does
|
|
//! not panic.
|
|
use bevy::{
|
|
prelude::*,
|
|
reflect::{TypePath, TypeUuid},
|
|
render::render_resource::{AsBindGroup, ShaderRef},
|
|
};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins((
|
|
DefaultPlugins,
|
|
MaterialPlugin::<FallbackTestMaterial>::default(),
|
|
))
|
|
.add_systems(Startup, setup)
|
|
.run();
|
|
}
|
|
|
|
fn setup(
|
|
mut commands: Commands,
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
mut materials: ResMut<Assets<FallbackTestMaterial>>,
|
|
) {
|
|
commands.spawn(MaterialMeshBundle {
|
|
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
|
|
material: materials.add(FallbackTestMaterial {
|
|
image_1d: None,
|
|
image_2d: None,
|
|
image_2d_array: None,
|
|
image_cube: None,
|
|
image_cube_array: None,
|
|
image_3d: None,
|
|
}),
|
|
..Default::default()
|
|
});
|
|
commands.spawn(Camera3dBundle {
|
|
transform: Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::new(1.5, 0.0, 0.0), Vec3::Y),
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
#[derive(AsBindGroup, Debug, Clone, TypePath, TypeUuid)]
|
|
#[uuid = "d4890167-0e16-4bfc-b812-434717f20409"]
|
|
struct FallbackTestMaterial {
|
|
#[texture(0, dimension = "1d")]
|
|
#[sampler(1)]
|
|
image_1d: Option<Handle<Image>>,
|
|
|
|
#[texture(2, dimension = "2d")]
|
|
#[sampler(3)]
|
|
image_2d: Option<Handle<Image>>,
|
|
|
|
#[texture(4, dimension = "2d_array")]
|
|
#[sampler(5)]
|
|
image_2d_array: Option<Handle<Image>>,
|
|
|
|
#[texture(6, dimension = "cube")]
|
|
#[sampler(7)]
|
|
image_cube: Option<Handle<Image>>,
|
|
|
|
#[texture(8, dimension = "cube_array")]
|
|
#[sampler(9)]
|
|
image_cube_array: Option<Handle<Image>>,
|
|
|
|
#[texture(10, dimension = "3d")]
|
|
#[sampler(11)]
|
|
image_3d: Option<Handle<Image>>,
|
|
}
|
|
|
|
impl Material for FallbackTestMaterial {
|
|
fn fragment_shader() -> ShaderRef {
|
|
"shaders/fallback_image_test.wgsl".into()
|
|
}
|
|
}
|