Can you set exported properties with units like built in properties?

Godot Version

4,2

Question

In Godot, “bulit-in” properties such as transformations have units to help make it clear what they are used for -
image

I have some properties in my template that I’d like to give a unit to make it easier for new developers to use. Is there a way to annotate a property so that it has the unit of measurement, or using the _get_property_list() method?

Sure, you can use the suffix property in the @export annotation, like @export("suffix:coins") var price:int = 5. It should display in the editor similar as the example you used.

Check more usage examples in this video from GDQuest:

1 Like

Thank you! Unfortunately it seems you can’t use hints with just @export so I had to use this instead:

@export_range(0, 300, 1, "suffix:px", "or_greater", "or_less", "hide_slider") var jump_height : int = 2.5:

A bit more clunky then I would like, but it works!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.