How can I make a resource emit changed signal by default whenever its properties are modified?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Xrayez

I find myself in an awkward situation when I create a custom resource similar to Material in nature and end up doing this:

extends Resource
class_name CustomMaterial

export(bool) var tear_down_enabled setget set_tear_down_enabled
export(float) var tear_down_threshold setget set_tear_down_threshold
export(float) var tear_down_delay setget set_tear_down_delay
export(bool) var destroy_on_tear_down setget set_destroy_on_tear_down
export(float) var destroy_threshold setget set_destroy_threshold
export(float) var destroy_delay setget set_destroy_delay

func set_tear_down_enabled(p_tear_down_enabled):
    tear_down_enabled = p_tear_down_enabled

func set_tear_down_threshold(p_tear_down_threshold):
    tear_down_threshold = p_tear_down_threshold

func set_tear_down_delay(p_tear_down_delay):
    tear_down_delay = p_tear_down_delay

func set_destroy_on_tear_down(p_destroy_on_tear_down):
    destroy_on_tear_down = p_destroy_on_tear_down

func set_destroy_threshold(p_destroy_threshold):
    destroy_threshold = p_destroy_threshold

func set_destroy_delay(p_destroy_delay):
    destroy_delay = p_destroy_delay

I connect the changed signal to whatever node might be interested in this custom material. What I’d like to do is to avoid writing these setter methods per property over and over, but have the resource emit changed signal by default. I’ve even created a snippet to speed up writing stuff like that. But I’m almost sure there must be a better way, any suggestions?

:bust_in_silhouette: Reply From: Dlean Jeans

This seems to be a bug.