您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

choices_box.gd 555 B

4 年前
4 年前
4 年前
4 年前
1234567891011121314151617181920212223242526
  1. extends VBoxContainer
  2. class_name ChoicesBox
  3. signal choice_made
  4. export var button_template : PackedScene
  5. func on_choice_made(marker):
  6. emit_signal("choice_made", marker)
  7. func on_choices(choices_list):
  8. show()
  9. for choice in choices_list:
  10. var choiceButton = button_template.instance()
  11. choiceButton.text = choice["text"]
  12. choiceButton.connect("pressed", self, "on_choice_made", [choice])
  13. add_child(choiceButton)
  14. var res = yield(self, "choice_made")
  15. hide()
  16. clear()
  17. return res
  18. func clear():
  19. for child in get_children():
  20. child.queue_free()