Godot Version
4.2.1
Question
Hi everyone,
I’m having some trouble with setting up tabs using a TabContainer for my game. I’ll add the code below, but the error monitor is showing the “Unexpected identifier in class body” message, and I’m not quite sure why. I’ve followed a reasonably new guide online to try and set this up so it may just be that an update has gonked what I’m trying to do. Any assistance would be appreciated. All lines causing problems I’ll mark with a " * ".
extends TabContainer
var tab1 = Control.new()
tab1.name = “Tab 1” *
tab_container.add_child(tab1) *var tab2 = Control.new()
tab2.name = “Tab 2” *
tab_container.add_child(tab2) *var tab3 = Control.new()
tab3.name = “Tab 3” *
tab_container.add_child(tab3) *var tab4 = Control.new()
tab4.name = “Tab 4” *
tab_container.add_child(tab4) *var tab5 = Control.new()
tab5.name = “Tab 5” *
tab_container.add_child(tab5) *var tab6 = Control.new()
tab6.name = “Tab 6” *
tab_container.add_child(tab6) *tab_container.set_tab_title(0, “Politics”) *
tab_container.set_tab_title(1, “Provinces”) *
tab_container.set_tab_title(2, “Economy”) *
tab_container.set_tab_title(3, “Trade”) *
tab_container.set_tab_title(4, “Research”) *
tab_container.set_tab_title(5, “Military”) *tab_container.tab_align = TabContainer.ALIGN_TOP *
func _ready():
TabContainer.connect(“tab_changed”, self, “_on_TabContainer_tab_changed”)func _on_TabContainer_tab_changed(tab_index):
print("Switched to tab: ", tab_index)