Skip to content

Instantly share code, notes, and snippets.

@me2beats
Created June 29, 2021 03:05
Show Gist options
  • Save me2beats/818feaee3f46cb4a06183eeeb6fdb82c to your computer and use it in GitHub Desktop.
Save me2beats/818feaee3f46cb4a06183eeeb6fdb82c to your computer and use it in GitHub Desktop.
get signal last in frame emitting
# not reusable/ abstraction needed
tabcont.connect("tab_changed", self, 'on_signal_tab_changed')
connect("tab_changed__last_in_frame", self, "on_tab_changed__last_in_frame")
signal tab_changed__last_in_frame
var started: = false
var result:int
func on_signal_tab_changed(tab:int):
result = tab
if !started:
started = true
yield(VisualServer, "frame_pre_draw")
# yield(get_tree(), "idle_frame")
emit_signal('tab_changed__last_in_frame', result)
started = false
# ensures this is the most recent emitted signal in the frame
func on_tab_changed__last_in_frame(tab):
printt('tab changed!', tab)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment