Is there a way to identify the group or subgroup of exported variables?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Meepophobia
@export_group("Health")
@export var base_health: float = 100.0
@export var health_regeneration: float = 0.0

@export_group("Resistance")
@export var armour: float = 1.0
@export var magic_resistance: float = 0.0

I want to see if there is a property or method that I can get which group each variable belongs to.

I don’t think so; it’s an editor feature but don’t quote me on that. It might be worth a poke around in the source to see what the engine does, although I wouldn’t be surprised if there’s no public API for it.

However, not sure why it’s useful so do please let a curious reader know why you’d want to do something like this. Perhaps, rather than groups, I can see this overlapping with Resources where, rather than group things in the Inspector, they properties are naturally aligned with their Resource; e.g. the Health Resource has a base_health (etc). This way, the properties can only come from the Health Resource (and so on).

Hopefully that’s clear? Resources are a pretty cool concept and very powerful.

spaceyjase | 2023-06-27 10:00

Thanks for the info.

I have these exports in resources, and I wanted to emit a different signal for each variable group.
For example, emit health_stats_changed if base_health and health_regenration changed and emit resistance_stats_changed if armour and magic_resistance changed.

I want to do something like this in _set method if a method like get_property_group exists

func _set(property: String, value) -> bool:
    set(property, value)
    match get_property_group(property):
        "Health":
            health_stats_changed.emit()
        "Resistance":
            resistance_stats_changed.emit()
    return true

This is to avoid writing a setter function for all the variables in a resource file.

Meepophobia | 2023-06-27 10:47