The OptionButton node offers the functionality of a drop-down list that allows a user to choose a single item from that list. However, in Godot, the way it works is not the way it seems.
While I was doing my job I ran into unexpected behaviour of Godot’s OptionButton. The OptionButton didn’t send the ID I assigned! It send the index number of the option in the list.
We’ll setup a small demo scene with a CanvasLayer, Control, and add an OptionButton on top. We’ll add a few entries to the OptionButton using code because that is how most people will use it.
Then we’ll setup a signal to the script to see what the output of each option is. Last, I will show you how to make the OptionButton behave in a way that will provide the expected outcome.
Code and project is available for download: https://github.com/VidyaGameMaka/godot4tutorial/tree/main/optionbuttontest