lots of new files
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
use bevy::color::palettes::basic::*;
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub struct MaterialPlugin;
|
||||
impl Plugin for MaterialPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, create_materials);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct MaterialHandles {
|
||||
pub color_material_handles: Vec<Handle<ColorMaterial>>,
|
||||
}
|
||||
|
||||
pub const COLORS: [Srgba; 16] = [
|
||||
AQUA, BLACK, BLUE, FUCHSIA, GRAY, GREEN, LIME, MAROON, NAVY, OLIVE, PURPLE, RED, SILVER, TEAL,
|
||||
WHITE, YELLOW,
|
||||
];
|
||||
|
||||
pub fn create_materials(mut commands: Commands, mut materials: ResMut<Assets<ColorMaterial>>) {
|
||||
let color_handles = COLORS
|
||||
.iter()
|
||||
.map(|&color| materials.add(ColorMaterial::from_color(color)))
|
||||
.collect();
|
||||
|
||||
commands.insert_resource(MaterialHandles {
|
||||
color_material_handles: color_handles,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user