Skip to content

Commit

Permalink
use NumberAttributes<T> for int T, not NumberAttributes<f32> for all
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobhellermann committed Jan 21, 2021
1 parent b2aeb17 commit 28fa524
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/all_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl Default for CustomEnum {

#[derive(Inspectable, Debug, Default)]
struct NoiseSettings {
#[inspectable(max = 8)]
octaves: u8,
frequency: f32,
lacunarity: f32,
Expand All @@ -51,6 +52,6 @@ fn main() {
}

// TODO: make ChangedRes work
fn data(data: Res<Data>) {
dbg!(data);
fn data(_data: Res<Data>) {
// dbg!(data);
}
2 changes: 1 addition & 1 deletion src/impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<T> NumberAttributes<T> {
macro_rules! impl_for_num {
($ty:ident $(default_speed=$default_speed:expr)? ) => {
impl Inspectable for $ty {
type FieldOptions = NumberAttributes<f32>;
type FieldOptions = NumberAttributes<$ty>;

fn ui(&mut self, ui: &mut egui::Ui, options: Options<Self::FieldOptions>) {
let mut widget = widgets::DragValue::$ty(self);
Expand Down
22 changes: 22 additions & 0 deletions tests/number_attributes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use bevy::math::prelude::*;
use bevy_inspector_egui::Inspectable;

#[derive(Inspectable)]
struct IntegerAttribues {
#[inspectable(min = 2, max = 2, speed = 0.1)]
a: u8,
// b: u16,
// c: u32,
// d: u64,
// e: i8,
// f: i16,
#[inspectable(min = -2)]
g: i32,
// h: i64,
i: f32,
#[inspectable(min = 0.1, max = 0.2)]
j: f64,
#[inspectable(min = Vec2::new(0.1, 0.2))]
k: Vec2,
l: Vec3,
}

0 comments on commit 28fa524

Please sign in to comment.