diff --git a/crates/bevy_render/src/color/mod.rs b/crates/bevy_render/src/color/mod.rs index 4fe72e7c3b348..4b9574dc22a75 100644 --- a/crates/bevy_render/src/color/mod.rs +++ b/crates/bevy_render/src/color/mod.rs @@ -250,10 +250,14 @@ impl Color { /// # use bevy_render::color::Color; /// let color = Color::hex("FF00FF").unwrap(); // fuchsia /// let color = Color::hex("FF00FF7F").unwrap(); // partially transparent fuchsia + /// + /// // A standard hex color notation is also available + /// assert_eq!(Color::hex("#FFFFFF").unwrap(), Color::rgb(1.0, 1.0, 1.0)); /// ``` /// pub fn hex>(hex: T) -> Result { let hex = hex.as_ref(); + let hex = hex.strip_prefix('#').unwrap_or(hex); // RGB if hex.len() == 3 { diff --git a/examples/3d/pbr.rs b/examples/3d/pbr.rs index 926a7eadfb577..c3159cff3fcea 100644 --- a/examples/3d/pbr.rs +++ b/examples/3d/pbr.rs @@ -30,7 +30,7 @@ fn setup( .unwrap(), ), material: materials.add(StandardMaterial { - base_color: Color::hex("ffd891").unwrap(), + base_color: Color::hex("#ffd891").unwrap(), // vary key PBR parameters on a grid of spheres to show the effect metallic: y01, perceptual_roughness: x01, @@ -51,7 +51,7 @@ fn setup( .unwrap(), ), material: materials.add(StandardMaterial { - base_color: Color::hex("ffd891").unwrap(), + base_color: Color::hex("#ffd891").unwrap(), // vary key PBR parameters on a grid of spheres to show the effect unlit: true, ..default()