Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | exuin |
I have two preloaded scenes. I instance them through code and they are added as children. But they don’t show up! I printed out a bunch of stuff, and they exist, and apparently are visible (at least, visible = true) and their position is (0, 0), but they’re not offscreen. So where are they???
Also, when I created the nodes through code instead of preloading scenes they showed up (I changed to preloading scenes to make the code simpler).
Here is the relevant code:
const ScrollClass = preload("res://scenes_and_scripts/scenes/OptionScroll.tscn")
const ItemClass = preload("res://scenes_and_scripts/scenes/Item.tscn")
# Code cut out here
# Makes all of the icons for the options and then hides the ones not in use
func make_icons():
for i in range(len(images[0])): # Loops through front view images
var scroll = ScrollClass.instance()
items.add_child(scroll)
var item = ItemClass.instance()
scroll.get_child(0).add_child(item)
item.get_child(0).connect("pressed", self, "remove_cur_option")
item.get_child(0).disabled = false # I have to re-enable the button since it's disabled by default
var group = ButtonGroup.new()
button_groups.append(group)
for j in range(len(images[0][i])):
item = ItemClass.instance()
scroll.get_child(0).add_child(item)
var button = item.get_child(0)
button.texture_normal = images[0][i][j]
button.connect("gui_input", self, "on_item_pressed", [button, j])
button.group = group
item.get_child(1).text = image_names[0][i][j].capitalize()
scroll.hide()
items.get_child(0).show()