How to create a Min Max export variable

Godot Version

4.5.1 stable

Question

Hi, does anyone know how to add an export variable with a min and max widget, btw i’m talking abt the ones that you see in ParticleProcessMaterial (I want them integer based tho, instead of a slider)

I’ve heard that it’s only on the Particles Editor which means it cant be used on exported variables, but then could it be done on GDExtension (I’ve never used it before)

I’d really appreciate any help :blush:

@export_range(0,10,1) var min_example_value: float

@export_range(0,10,1) var max_example_value: float

func _process() → void:
	var clamped_value = clampf(clamped_value, min_example_value, max_example_value)

I don’t know about using that specific widget

this is a discussion I found on it but I don’t think you can get that interface easily

I know I can use export range, but export range doesnt let me set and get the min and max value. I could add 2 integer variables but that will make my inspector have a lot of export variables, even if they’re splitted in groups

min and max in particle material are actually 2 variables.

How does it look like 1 then? because that’s what I want, because I dont want to have a lot of exported variables in the inspector, it doesnt matter on script, I’ve also heard of EditorPlugins but they’re complicated and I don’t know if it’s worth it, Thank you tho!

From what I can find that it is a special interface for that node it is not accessible through gdscript

1 Like

Yeah I already knew that, but I just thought that it could be possible with GDExtension or a simple plugin, it is possible with EditorPlugins but they’re complicated and I don’t know if it’s worth it, Thank you tho!

Umm… how does it look like one? There are two numerical values and two sliders. If you look at the ParticleProcessMaterial you can clearly see that there is a min/max pair of variables for each of those properties. It can’t be a single value as you need two values to define a range.

So are you defining a range or just need a range for a variable. For the former you’ll need two values, for the latter there’s @export_range.

If you want a special look or functionality for those properties, you’ll have to make an EditorInspectorPlugin

I just wanted an integer range where I can choose it’s min and max value, so then i could use it in a randi_range() but I guess making an EditorPlugin just for that isn’t worth it so i’ll pass, Thanl you for the effort tho!

It’s two values then.

I’m in general annoyed by how much space the inspector eats up. In cases like this, especially if there are many such variables, I’d just use strings with some simple syntax convention. So for a range it may look like: "100-200". This is then parsed into integers at startup.

That said, making an inspector plugin is not a big deal either.

1 Like

ohh, that’s smart. Thank you!