This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello!
I'm trying to create a CustomButtonGroup resource type to work togheter with a CustomButton.
I want to get all nodes that is referencing a specific instance of this CustomButtonGroup and execute some code with that.
Eg:

In my custom resource

extends Resource
class_name MyButtonGroup

var group_name: String

func _init(new_name: String) -> void:
    group_name = new_name

func get_all_buttons() -> Array:
    #Here I want to get all nodes that are referencing to this instance
    return [button1, button2, etc]

func execute_custom_button_function() -> void:
    for button in get_all_buttons():
        button.custom_function()

And in my button

extends Button
class_name MyButton

var custom_button_group: MyButtonGroup

func custom_function():
    #Execute some code

I know that I can put some setget on the var custom_button_group inside my button and every time I change it, I append this button inside an array in the button_group, but I don't wanna to do that because I'll use this for others custom buttons too and to other situation so I might I can do this dynamically from the resource side.

I tried to read the ResourceLoader documentation but I couldn't make it work. I didn't find some question about it too.

Godot version v3.3.3
in Engine by (20 points)

Please log in or register to answer this question.

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.