lots of new files

This commit is contained in:
2026-03-04 10:20:13 +00:00
parent b70b9fc63d
commit 7b1d9a7e04
7 changed files with 221 additions and 1 deletions
+30
View File
@@ -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,
});
}