mirror of
https://github.com/bevyengine/bevy
synced 2024-11-23 05:03:47 +00:00
b6a647cc01
Adds a `default()` shorthand for `Default::default()` ... because life is too short to constantly type `Default::default()`. ```rust use bevy::prelude::*; #[derive(Default)] struct Foo { bar: usize, baz: usize, } // Normally you would do this: let foo = Foo { bar: 10, ..Default::default() }; // But now you can do this: let foo = Foo { bar: 10, ..default() }; ``` The examples have been adapted to use `..default()`. I've left internal crates as-is for now because they don't pull in the bevy prelude, and the ergonomics of each case should be considered individually.
22 lines
654 B
Rust
22 lines
654 B
Rust
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_startup_system(setup)
|
|
.run();
|
|
}
|
|
|
|
fn setup(
|
|
mut commands: Commands,
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
|
) {
|
|
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
|
|
commands.spawn_bundle(MaterialMesh2dBundle {
|
|
mesh: meshes.add(Mesh::from(shape::Quad::default())).into(),
|
|
transform: Transform::default().with_scale(Vec3::splat(128.)),
|
|
material: materials.add(ColorMaterial::from(Color::PURPLE)),
|
|
..default()
|
|
});
|
|
}
|