Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Larck_Drakengold |
The Problem:
I’ve been hunting around for documentation everywhere but cannot seem to find anything deeper than the basic node description.
I have a TabContainer with multiple Tabs within, and each tab is scripted to change its custom_style/panel stylebox texture resource on click. However, when I made the signal connection to the TabContainer, it gave me
func _on_tab_clicked(tab):
but then it also gave me an error about how the variable (tab) was not used, and to change it to (_tab). This doesn’t make it function at all. when I try to change the variable to an int based on what tab number it is, it yells at me again, saying
"error(line number): Expected an identifier for an argument. "
The Question:
How am I supposed to access these tabs signals to actually have them function? Below is the script I have currently:
extends TabContainer
onready var red = load("res://source/art/red_styleboxflat.tres")
onready var orange = load("res://source/art/orange_styleboxflat.tres")
onready var yellow = load("res://source/art/yellow_styleboxflat.tres")
onready var green = load("res://source/art/green_styleboxflat.tres")
onready var blue = load("res://source/art/blue_styleboxflat.tres")
onready var purple = load("res://source/art/purple_styleboxflat.tres")
onready var rainbow = load("res://source/art/rainbow_Styleboxtexture.tres")
onready var panel = get_stylebox("panel","")
func _on_red_tab_clicked(_tab):
panel.set_texture(red)
func _on_orange_tab_clicked(_tab):
panel.set_texture(orange)
func _on_yellow_tab_clicked(_tab):
panel.set_texture(yellow)
func _on_green_tab_clicked(_tab):
panel.set_texture(green)
func _on_blue_tab_clicked(_tab):
panel.set_texture(blue)
func _on_purple_tab_clicked(_tab):
panel.set_texture(purple)
func _on_rainbow_tab_clicked(_tab):
panel.set_texture(rainbow)
That “error” about an unused variable is actually just a warning and you can ignore it.
Eric Ellingson | 2020-03-19 16:41