I'm having trouble figuring out how to change a label node from another scene. What I want is for my game settings option to be able apply font changes to a label that is from another scene and it's script.
As you can see from the commented out code, I've tried @export, but I do not understand it well enough. Can I make certain nodes global from other scenes and scripts?
Title_Screen_Menu script:
`extends Control
#@export var TS_Button: Button
@onready var btn_TScreen1 = $/root/Title_Screen_Menu/VBoxContainer/Button1
#@onready var btn_TScreen2 = $/root/Title_Screen_Menu/VBoxContainer/Button2
#@onready var btn_TScreen3 = $/root/Title_Screen_Menu/VBoxContainer/Button3
#@onready var btn_TScreen4 = $/root/Title_Screen_Menu/VBoxContainer/Button4
func _ready() -> void:
_on_button_2_pressed()
pass
func _on_button_1_pressed() -> void:
pass # Replace with function body.
func _on_button_2_pressed() -> void:
pass # Replace with function body.
func _on_button_3_pressed() -> void:
get_tree().change_scene_to_file("res://assets/options_menu.tscn")
func _on_button_4_pressed() -> void:
get_tree().quit()`
Options_Menu script:
`extends Control
const Settings_Save_Path := "user://config_save.cfg"
@onready var label_bus1 = $Label_bus1
@onready var label_bus2 = $Label_bus2
@onready var label_bus3 = $Label_bus3
@onready var btn_1 = $HBoxContainer/Button
@onready var btn_2 = $HBoxContainer/Button2
@onready var btn_3 = $HBoxContainer/Button3
var config = ConfigFile.new()
var FontStyle = "res://assets/MechanicalBold.otf"
func _ready() -> void:
pass
func _on_check_box_toggled(button_pressed: bool) -> void:
if button_pressed == true:
label_bus1.add_theme_font_override("font", load("res://assets/MechanicalBold.otf"))
label_bus2.add_theme_font_override("font", load("res://assets/MechanicalBold.otf"))
label_bus3.add_theme_font_override("font", load("res://assets/MechanicalBold.otf"))
btn_1.add_theme_font_override("font", load("res://assets/MechanicalBold.otf"))
btn_2.add_theme_font_override("font", load("res://assets/MechanicalBold.otf"))
btn_3.add_theme_font_override("font", load("res://assets/MechanicalBold.otf"))
TitleScreenMenu.btn_TScreen1.add_theme_font_override("font", load("res://assets/MechanicalBold.otf")) # title screen button
FontStyle = "res://assets/MechanicalBold.otf"
print(FontStyle)
if button_pressed == false:
label_bus1.add_theme_font_override("font", get_theme_default_font())
label_bus2.add_theme_font_override("font", get_theme_default_font())
label_bus3.add_theme_font_override("font", get_theme_default_font())
btn_1.add_theme_font_override("font", get_theme_default_font())
btn_2.add_theme_font_override("font", get_theme_default_font())
btn_3.add_theme_font_override("font", get_theme_default_font())
print("Default Godot font used")`