Skip to content

Commit c661acf

Browse files
authored
Support export_range suffix (#85)
Godot allows exporting numeric properties with a unit / suffix. Exporting with `#[export(range(suffix = "km/h"))` should now show up in the editor.
1 parent a66a9b9 commit c661acf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

derive/src/attribute_ops.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ impl FieldExportOps {
269269
}
270270

271271
let step = ops.parsed.step.unwrap_or(1.0);
272-
let hint_string = format!("{},{},{}", ops.parsed.min, ops.parsed.max, step);
272+
let suffix = ops.parsed.suffix.as_deref().unwrap_or("");
273+
274+
let hint_string = format!(
275+
"{},{},{},suffix:{}",
276+
ops.parsed.min, ops.parsed.max, step, suffix
277+
);
273278

274279
result = Some(ExportMetadata {
275280
field: FIELD,
@@ -387,6 +392,7 @@ struct ExportRangeOps {
387392
min: f64,
388393
max: f64,
389394
step: Option<f64>,
395+
suffix: Option<String>,
390396
}
391397

392398
#[derive(FromMeta, Debug)]

0 commit comments

Comments
 (0)