 b6a647cc01
			
		
	
	
		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.
		
	
			
		
			
				
	
	
		
			28 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| /// An example of how to display a window in transparent mode
 | |
| /// [Documentation & Platform support.](https://docs.rs/bevy/latest/bevy/prelude/struct.WindowDescriptor.html#structfield.transparent)
 | |
| use bevy::{prelude::*, window::WindowDescriptor};
 | |
| 
 | |
| fn main() {
 | |
|     App::new()
 | |
|         // ClearColor must have 0 alpha, otherwise some color will bleed through
 | |
|         .insert_resource(ClearColor(Color::NONE))
 | |
|         .insert_resource(WindowDescriptor {
 | |
|             // Setting `transparent` allows the `ClearColor`'s alpha value to take effect
 | |
|             transparent: true,
 | |
|             // Disabling window decorations to make it feel more like a widget than a window
 | |
|             decorations: false,
 | |
|             ..default()
 | |
|         })
 | |
|         .add_startup_system(setup)
 | |
|         .add_plugins(DefaultPlugins)
 | |
|         .run();
 | |
| }
 | |
| 
 | |
| fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
 | |
|     commands.spawn_bundle(OrthographicCameraBundle::new_2d());
 | |
|     commands.spawn_bundle(SpriteBundle {
 | |
|         texture: asset_server.load("branding/icon.png"),
 | |
|         ..default()
 | |
|     });
 | |
| }
 |