+2 votes

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
    emit_signal("changed")

func set_tear_down_threshold(p_tear_down_threshold):
    tear_down_threshold = p_tear_down_threshold
    emit_signal("changed")

func set_tear_down_delay(p_tear_down_delay):
    tear_down_delay = p_tear_down_delay
    emit_signal("changed")

func set_destroy_on_tear_down(p_destroy_on_tear_down):
    destroy_on_tear_down = p_destroy_on_tear_down
    emit_signal("changed")

func set_destroy_threshold(p_destroy_threshold):
    destroy_threshold = p_destroy_threshold
    emit_signal("changed")

func set_destroy_delay(p_destroy_delay):
    destroy_delay = p_destroy_delay
    emit_signal("changed")

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?

in Engine by (1,378 points)

1 Answer

+1 vote

This seems to be a bug.

by (4,225 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.