making a dropdown/option menu
hello, so uh, im trying to make a dropdown menu for my game and using this video here
as reference.
But it gave me an invalid call.nonexistent function error.
here's the code :
extends Control
export (NodePath) var DropDown_path
onready var DropDown = get_node(DropDown_path)
func _ready():
add_items()
add item to drop down menu
func add_items():
DropDown.add_items("option 1")
DropDown.add_items("option 2")
DropDown.add_items("option 3")
DropDown.add_items("option 4")
from my understanding godot doesn't recognize the add_items function but it works just fine on the video,
maybe someone can give me a bit of insight ?
thank you a lot.
Answers
Are you sure, that DropDown in fact is the PopupMenu node and not the MenuButton? If it is the MenuButton you first have to call the get_popup() function, so it could be:
DropDown is an OptionButton node, made sure of it.
And it works just fine in the vids
That post is from 2016 so chances are high it's using godot 1.x or 2.x
Are you using godot 3.0.x perhaps?
Ok, this is a typo. Method is called add_item() and not add_items()
uh yes, i'm using godot 3.
kinda difficult to find a suitable godot 3 guide around
uh no, it is add_items()
Not in my Godot Version (3.0.6)
silly me, the code is on a control node which is the parent of the dropdown node,
no wonder i can't use add_item().