0 votes

I'am making an option button, and i want to change the color of a label that is in another scene, this is my actual code

extends HBoxContainer

export var node = ""

func _on_OptionBox_focus_entered():
    get_node("OptionLabel").add_color_override("font_color", Color(1,1,0.3,0.8))
    get_node("MinusButton").add_color_override("font_color", Color(1,1,0.3,0.8))
    get_node("PlusButton").add_color_override("font_color", Color(1,1,0.3,0.8))
    get_node(node).add_color_override("font_color", Color(1,1,0.3,0.8))
Godot version 3.4.2
in Engine by (33 points)
edited by

Is the other scene in the same scene tree as this script?

no, it's not

1 Answer

+2 votes
Best answer

If its not in the same scene tree you will need to have a autoload script to pass the information from one scene to another.

Create a script and go into the project options. You will see autoload options. In this set that script to autoload. This will mean you will always load that script in every other scene which loads.

Now you can put a variable in that script, perhaps an array with all the colour settings you want. When someone changes it in this scene amend the array in the autoload script. The when you load the script with the label in use the settings in the autoload scripts variables to set the colour in the _ready function.

by (1,635 points)
selected by
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 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 webmaster@godotengine.org with your username.